m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-03 22:42:04 +0100
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-11-03 22:42:04 +0100
commit2b7a2ba55ea5ae832a79a5902365020b4a36467d (patch)
treeb70415ceb9996fd227289f0070743dc02ed2232a
parent04be1590eb9270ed259bfe08bd6273dac38444b0 (diff)
Add bash sheet
-rw-r--r--bash.md23
1 files changed, 23 insertions, 0 deletions
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