Sed

From Dave's wiki
Jump to navigation Jump to search

Some cool sed tips from https://github.com/stephenturner/oneliners

#Number each line in file.txt:
sed = file.txt | sed 'N;s/\n/ /'

#Trim leading and trailing whitespace in file.txt:
sed 's/^[ \t]*//; s/[ \t]*$//' file.txt

#Delete blank lines in file.txt:
sed '/^$/d' file.txt