sed:delete:delete_both_leading_and_trailing_whitespace_from_each_line
This is an old revision of the document!
Table of Contents
SED - Delete - Delete BOTH leading and trailing whitespace from each line
sed 's/^[ \t]*//;s/[ \t]*$//'
NOTE: Aligns all text flush left.
NOTE: The expression '\t' is used to indicate a tab character (0x09) in the scripts.
Some versions of sed do not recognize the '\t' abbreviation, so when typing these scripts from the command line, you should press the TAB key instead.
'\t' is supported as a regular expression.
Example
Example
cat input.txt | sed 's/^[ \t]*//;s/[ \t]*$//' > output.txt
sed/delete/delete_both_leading_and_trailing_whitespace_from_each_line.1597577257.txt.gz · Last modified: 2020/08/16 11:27 by 192.168.1.1