67 / 102
sed
sed- Stream editor. Filter text in a pipeline.
Examples:
sed "1,32 d" file.txt- Delete lines 1 through 32
sed 's/[ ^t]*$//' file.txt- Delete trailing whitespace (spaces/tabs) from end of each line.
Delete both leading and trailing whitespace from each line.- sed 's/^[ ^t]*//;s/[ ^t]*$//' file.txt
sed 's/foo/bar/g' file.txt- Replace all instances of "foo" with "bar".
sed '/^Delete/d' file.txt- Delete lines starting with "Delete".
sed --in-place 's/^\(.\{20\}\).*/\1/g' file- Replace all lines with only their first 20 characters.
- sed, a stream editor - http://www.gnu.org/software/sed/manual/sed.html
- http://sed.sourceforge.net/