User Tools

Site Tools


awk:delete_both_leading_and_trailing_whitespaces_from_each_line

This is an old revision of the document!


AWK - Delete both leading and trailing whitespaces from each line

awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }' file.txt

Example

file.txt aaaaa bbbbb ccccc ddddd eeeee
 

returns:

aaaaa
bbbbb
ccccc
ddddd
 
eeeee
awk/delete_both_leading_and_trailing_whitespaces_from_each_line.1609949704.txt.gz · Last modified: 2021/01/06 16:15 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki