Resources

$ locate FILENAME

Find executable

Show location of an executable that is in a bin directory.

$ which myscript

Edit the file.

$ open $(which myscript)

Use code in place of open, to use VS Code IDE.

List

Pass output as a list, where using a pipe is not possible.

COMMAND <(COMMAND)

e.g.

source <(kubectl completion bash)
diff <(ls dirA) <(ls dirB)

Conditions

See guide

How to check

if [[ -f "$FILE" ]]; then
    echo "$FILE exist"
fi
[[ -f "$FILE" ]] && echo 'yes' || echo 'no'

x=$([[ -f "$FILE" ]] && 'yes' || 'no')

# Use curly braces. Maybe round brackets?
[ -f "$FILE" ] && { echo "$FILE exist"; cp "$FILE" /tmp/; }

Path check options

[[ -e FILE ]] 	Exists
[[ -h FILE ]] 	Symlink
[[ -d FILE ]] 	Directory

[[ -s FILE ]] 	Size is > 0 bytes

[[ -f FILE ]] 	File

[[ -r FILE ]] 	Readable
[[ -w FILE ]] 	Writable
[[ -x FILE ]] 	Executable

[[ FILE1 -nt FILE2 ]] 	1 is more recent than 2
[[ FILE1 -ot FILE2 ]] 	2 is more recent than 1
[[ FILE1 -ef FILE2 ]] 	Same files