bash

At the moment, this is just a dumping ground for useful tidbits I find / need in my daily work. At some point I will get around to organizing and formalizing. Parameter Expansion Bash reference manual Slice a string a="teleport" b=${a:4:7} echo $b > port Replace a portion of a string The pattern is ${parameter/pattern/string} to replace the first occurence of pattern with string or ${parameter//pattern/string} to replace all occurrences....

March 10, 2022 · 1 min · Me

awk

Basic syntax awk [ options ] script filename Where script is either a single awk command or file of awk commands. Awk commands look like this: TODO and filename can be omitted if you’re piping in standard input. Commands Options Examples Length of the longest line in a file awk '{ if (length($0) > max) max = length($0) }; END { print max }' file Selecting, filtering, and basic arithmetic Sum a field, specify delimiter awk -F '\t' '{print sum+=$1;} END {print sum}' file....

February 7, 2022 · 1 min · Me

Sed

This is an ongoing work in progress, please let me know if you have any suggestions/feedback. Basic syntax sed [ options ] script filename Where script is either a single sed command or file of sed commands (must use with -f option). Sed commands look like this: action/pattern/replacement/flag Filename can be omitted if you’re piping in standard input. Actions p: print s: substitute s accepts the following flags which are appended to the end of the command (e....

January 30, 2022 · 2 min · Me