sed:remove_white-space_including_tabs
This is an old revision of the document!
Table of Contents
SED - Remove white-space
Remove leading and trailing whitespace from each line
cat input.txt | sed 's/^[ \t]*//;s/[ \t]*$//' > output.txt
Remove all whitespace (including tabs) from beginning of string
echo " This is a test" | sed -e 's/^[ \t]*//'
result:
This is a test
Where,
- s/ : Substitute command ~ replacement for pattern (^[ \t]*) on each addressed line
- ^[ \t]* : Search pattern ( ^ – start of the line; [ \t]* match one or more blank spaces including tab)
- ** : Replace (delete) all matched pattern —-
sed/remove_white-space_including_tabs.1597577160.txt.gz · Last modified: 2020/08/16 11:26 by 192.168.1.1