Section: Shells

Sed

Oct 31, 2020 5 min.

SED: Delete lines from file (delete command) SED: Extract specific lines from a file (print command) To extract line 3 and 5 sed -n -e '3p' -e '5p' my.txt or semi colon separated sed -n -e '3p;5p' my.txt Extract range of lines - e.g. get lines from 2 to 5 sed -n -e '2,5 p' my.txt Extract last line of the file sed -n -e '$ p' my.

Extract Data From Json String

Jan 8, 2019 1 min.

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