Posts

Showing posts with the label tricks

Bash Scripting Cookies

- Passing arguments to a Bash script. `basename $0` in the script will list the name of the script without the path. `dirname $0` in the script will list the absolute path of the script without the name. `$0` will list the full path 'URI' of the script. `$#` will list the count of the arguments passed to the script. `$*` will be listing all the arguments passed to the script. `$1` will be listing the first argument passed to the script. - If conditional statements Condition Meaning [ -a FILE ] True if FILE exists. [ -b FILE ] True if FILE exists and is a block-special file. [ -c FILE ] True if FILE exists and is a character-special file. [ -d FILE ] True if FILE exists and is a directory. [ -e FILE ] True if FILE exists. [ -f FILE ] True if FILE exists and is a regular file. [ -g FILE ] True if FILE exists and its SGID bit is set. [ -h FILE ] True if FILE exists and is a symbolic link. [ -k FILE ] True if FILE exists and its sticky bit is s...