Skip to content

Bash Commands

superstringer edited this page Apr 15, 2019 · 1 revision

Get N random number of lines from file

$ shuf -n N input.txx > output.txt

Count number of lines in file

$ wc -l file.txt

Convert tabs to spaces in bash

$ expand -t 4 input.txt > output.txt

Select range of lines from text file

$ sed -n 101,215p infile.csv > outfile.csv

Delete line(s) from text file

$ sed -e '17d' infile.txt > outfile.txt
$ sed -e '3d;11,17d;45d' infile.txt > outfile.txt

To create a backup of the original file use -i.bak with the command

$ sed -i.bak -e '3d;11,17d;45d' infile.txt

Check picture history info

$ strings pic.png | less

Clone this wiki locally