bash script file test operators.
-
Take into account the main readme for this section. README first.
See the The GNU bash documentation for more test operators at: https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html
Code.
$ cat learnbash.sh #!/bin/bash read -p "Enter a full pathname: " Pathname if [ -f "$Pathname" ] then echo "I'm a file" else echo "I'm not a file" fi
Run the script.
$ ./learnbash.sh Enter a full pathname: /usr/bin/zsh I'm a file $ ./learnbash.sh Enter a full pathname: /usr/bin I'm not a file
© Lightnetics 2024