Posts in 2021
-
Run a Shell Script With Environment Variables in One Line
Monday, July 19, 2021 in Shell
Categories:
less than a minute
env1=a env2=b e.g. my_var1=abc my_var2=xyz ./myscript.sh
Posts in 2020
-
Sed
Saturday, October 31, 2020 in Shell
Categories:
6 minute read
SED: Delete lines from file (delete command) Description Command Input Output Delete the line 2 and 5from the file my.txt sed -e '2d' -e '5d' my.txt Or sed -e '2d;5d' my.txt line - one line - two line - three line - four line - five line - six line - …
Posts in 2019
-
Extract Data From Json String
Tuesday, January 08, 2019 in Shell
Categories:
less than a minute
myjson='{"somekey":"someval"}' v=`echo $myjson | jq '.somekey'` echo $v output: "someval" # Get the value wihout quotes v=`echo $myjson | jq -r '.somekey'` echo $v output: someval