Bash Cheat Sheet
Some bash utils that I almost always to forget.
1
Ctrl-o - used when browsing history command (Ctrl-r), it will execute the command, and fetch the next one from the history.
To copy some files to a backup to have the same extension name
1
2
cp a.txt a.txt.a-long-text-for-testing-that-i-dont-want-to-retype
cp b.txt b.txt.${_##*.}
To separate filename and extension name
1
2
3
fname="test.tar.gz"
echo "${fname%.*}" # test.tar
echo "${fname##*.}" # gz
This post is licensed under CC BY 4.0 by the author.