Two pretty useful sed commands:
 Show a particular line only
- sed -n ‘3p’ dataOutput/posprocessed1userstudy3.log (shows 3rd line only)
- Actually this has some performance bottlenecks. Take a look at the better options below
- sed ‘2q;d’ train.csv
- Better option. This prints the 2nd line of the file.
- head -n 2 train.csv | tail -1
- Example using head and tail
 Dealing with range of lines:
sed -n '20,40p;41q' file_name
- This has a wonderful explanation of how the options n, p, q, d work.
- delete top n lines of a file
 Prepend Text to a File at the Command Line
- sed -i ‘1i id,gender,age’ mldataset.csv (Prepend Text to a File at the Command Line)
 Remove blank lines from file.
- sed ‘/^$/d’ input.txt > output.txt
- grep -v ‘^$’ input.txt > output.txt
(Both grep and sed use special pattern ^$ that matchs the blank lines. Grep -v option means print all lines except blank line.)