sed:remove_white-space_including_tabs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sed:remove_white-space_including_tabs [2020/08/16 11:26] โ 192.168.1.1 | sed:remove_white-space_including_tabs [2020/08/16 11:29] (current) โ removed 192.168.1.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SED - Remove white-space ====== | ||
- | |||
- | |||
- | |||
- | |||
- | ===== Remove leading and trailing whitespace from each line ===== | ||
- | |||
- | <code bash> | ||
- | cat input.txt | sed 's/^[ \t]*//;s/[ \t]*$//' | ||
- | </ | ||
- | |||
- | |||
- | ----- | ||
- | |||
- | ===== Remove all whitespace (including tabs) from beginning of string ===== | ||
- | |||
- | <code bash> | ||
- | echo " | ||
- | </ | ||
- | |||
- | result: | ||
- | |||
- | <code bash> | ||
- | 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