From 2b7a2ba55ea5ae832a79a5902365020b4a36467d Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 3 Nov 2019 22:42:04 +0100 Subject: Add bash sheet --- bash.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bash.md diff --git a/bash.md b/bash.md new file mode 100644 index 0000000..c8b2004 --- /dev/null +++ b/bash.md @@ -0,0 +1,23 @@ +# Bash scripting + +## String manipulation + +Remove shortest from end + + ${VAR%substr} + # e.g. + ${FILEPATH%.*}.out # change extension from whatever to .out + +Remove longest from start + + ${VAR#substr} + # e.g. + ${FILEPATH##*/} # get only file name portion + +%% - longst from end, # - shortest from start + +## Control flow + +Loop over files + + for file in glob/*; do something $file; done -- cgit v1.2.3