Friday, May 3, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 13442  / 3 Years ago, sat, november 20, 2021, 4:29:58

I'm looking at the '.profile' file in my home directory and I see different options used with the IF statement:



if [ -n "$BASH_VERSION" ]; then...
...
if [ -f "$HOME/.bashrc" ]; then...
...
if [ -d "$HOME/bin" ] ; then...
...


What is the meaning and use of the -n -f and -d options here and generally in other bash scripts?


More From » command-line

 Answers
1

-f and -d are file test operators options, namely:



-f file is a regular file, not a directory



-d file is a directory



-n is comparison operator option. It returns "true" when the string following the option is not null.


[#4061] Sunday, November 21, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sertold

Total Points: 445
Total Questions: 123
Total Answers: 113

Location: Burundi
Member since Wed, Sep 28, 2022
2 Years ago
;