| | | | | linguist.page@gmail.com

Replace text in a file using sed

Type here
sed 's/old/new/g' filename

Edit a file in place with sed

Type here
sed -i 's/oldword/newword/g' corpus.txt

Delete blank lines from a file

Type here
sed '/^$/d' corpus.txt > corpus_clean.txt

Strip leading and trailing whitespace from each line

Type here
sed 's/^[ \t]*//;s/[ \t]*$//' corpus.txt
Type here
sed -n '42p' corpus.txt
Type here
sed -n '100,200p' corpus.txt