User Tools

Site Tools


awk:delete_trailing_whitespace_and_tabs_from_the_end_of_each_line

AWK - Delete trailing whitespace and tabs from the end of each line

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

Example

file.txt
aaaaa
    bbbbb
        ccccc
 ddddd
 
       eeeee

returns:

aaaaa
    bbbbb
        ccccc
 ddddd
 
       eeeee
awk/delete_trailing_whitespace_and_tabs_from_the_end_of_each_line.txt · Last modified: 2021/01/06 16:19 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki