Bash Scripting
command interpreter / shell
return to previous dir
cd -
move to some-dir and return at any moment
move to background, and bring up again
reverse search through history
Ctrl + R
add timestamp to history. Ignore commands if started by whitespace
run 2 commands in a row
ls -l; echo "i am the second command"
only run second command if first succeeds
ls -l && echo "i am the second command"
follow log-file in real-time
tail -f <some-log-file>
delete content of file
truncate -s 0 <some-file>
ensure output is columnized
mount | column -t
find out which shell is used from a given terminal window
:
echo $SHELL
find the location of bash
:
which bash
create file
vim some_file.sh
add shebang to top of file
#!/usr/env/bin bash
make the file executable
sudo chmod +x some_file.sh
variables
if statements
while loops
math functions
exit codes
for loops
functions
case statements
scheduling jobs
arguments