Bash commands are mainly supported in MacOS, Linux but also support in Windows. You can use integrated tools for using bash on these platforms.
👉 Note: Terminal + ZSH
Ctrl
+ C
: interrupt current tasks.Ctrl
+ L
: clear the screen.Tab
: autocomplete the commands / directories / file names / ....Ctrl
+ Shift
+ V
: paste from clipboard.Enter
to continue to read, q
to quit.Ctrl
+ A
: move cursor to the beginning of the line.# run at once
command_1 && command_2
.sh
file<aside>
☝️ #!/bin/bash
tells your terminal to run the script with bash
. There are also zsh
, sh
, fish
,...
</aside>
# using script: file.sh
#!/bin/sh
echo 'some info'
command_1
command_2
# and then sh file.sh
# with arguments
$file1 = $1
wc $file1 # word count
# multiple input args
for FILE1 in "$@"; do
wc $FILE1
done
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
echo $NAME
wc $FILE
# how to use?
sh test.sh -n "ThiD" -f test.md
# all files / folders containing 'abc'
ls | grep -i abc
# find command lines containing 'abc'
dpkg -l | grep -i abc