How to delete ending/trailing spaces using awk,sed,perl?
Input:(each line has extra spaces at the end)
3456 565
3 7
35 878
Expected output:
3456 565
3 7
35 878
How to delete ending/trailing spaces using awk,sed,perl?
Input:(each line has extra spaces at the end)
3456 565
3 7
35 878
Expected output:
3456 565
3 7
35 878
sed 's/ *$//'
Can anyone post command for awk and perl?
awk:
$ awk 'sub(/ *$/, "", $0)' inputfile
# or simply (although it removes all unnecessary whitespace)...
$ awk '$1=$1' inputfile
Perl:
perl -pe 's/ +$//' file
awk 'sub(/ *$/, "")' inputfile