Conditionals - 14paxton/Linux Wiki

use a variable set by a script

act=$(gh auth status -t >>(tee -a) 2>&1 | sed -n 's/.*Token: //p');
if [ "$act" == *"$GH_TOKEN"* ](/14paxton/Linux/wiki/-"$act"-==-*"$GH_TOKEN"*-)
then do things
fi

https://linuxize.com/post/bash-check-if-file-exists/

Check if File does Not Exist

Similar to many other languages, the test expression can be negated using the ! (exclamation mark) logical not operator:

FILE=/etc/docker if [ ! -f "$FILE" ]; then echo "$FILE does not exist." fi Copy Same as above:

[ ! -f /etc/docker ] && echo "$FILE does not exist."

Check if Multiple Files Exist

Instead of using complicated nested if/else constructs you can use -a (or && with [[) to test if multiple files exist:

if [ -f /etc/resolv.conf -a -f /etc/hosts ]; then echo "Both files exist." fi Copy if -f /etc/resolv.conf && -f /etc/hosts ; then echo "Both files exist." fi

File test operators

The test command includes the following FILE operators that allow you to test for particular types of files:

-b FILE - True if the FILE exists and is a special block file.

-c FILE - True if the FILE exists and is a special character file.

-d FILE - True if the FILE exists and is a directory.

-e FILE - True if the FILE exists and is a file, regardless of type (node, directory, socket, etc.).

-f FILE - True if the FILE exists and is a regular file (not a directory or device).

-G FILE - True if the FILE exists and has the same group as the user running the command.

-h FILE - True if the FILE exists and is a symbolic link.

-g FILE - True if the FILE exists and has set-group-id (sgid) flag set.

-k FILE - True if the FILE exists and has a sticky bit flag set.

-L FILE - True if the FILE exists and is a symbolic link.

-O FILE - True if the FILE exists and is owned by the user running the command.

-p FILE - True if the FILE exists and is a pipe.

-r FILE - True if the FILE exists and is readable.

-S FILE - True if the FILE exists and is a socket.

-s FILE - True if the FILE exists and has nonzero size.

-u FILE - True if the FILE exists, and set-user-id (suid) flag is set.

-w FILE - True if the FILE exists and is writable.

-x FILE - True if the FILE exists and is executable.