Bash (Unix Shell)

Bash command are mainly supported MacOS, Linux. On Windows, you can use WSL, it’s easy to setup and can use full-featured.

Note: Terminal ZSH

Tools

Hotkeys

Multiple commands

Terminal window
# run at once
command_1 && command_2

.sh file

Note+

#!/bin/bash tells your terminal to run the script with bash. There are also zshshfish,…

Multi-column

Note

file.sh
# using script: file.sh
#!/bin/sh
echo 'some info'
command_1
command_2
Note

file.sh
# using script: file.sh
# with arguments
$file1 = $1
wc $file1 # word count
# multiple input args
for FILE1 in "$@"; do
wc $FILE1
done
Note

Terminal window
NAME="defaut" # default value! DON'T HAVE SPACE!!!
# with flags
while getopts n:f: option; do
case "${option}"
in
n) NAME=${OPTARG};;
f) FILE=${OPTARG};;
esac
done

Search/grep/sed

Multi-column

Note

Terminal window
# all files / folders containing 'abc'
ls | grep -i abc
Note

Terminal window
# find command lines containing 'abc'
dpkg -l | grep -i abc
Note

/usr/lib/python3/dist-packages
# search and extract a part of result
pip show numpy
pip show numpy | sed -n 's/Location: //p'
# /usr/lib/python3/dist-packages