How do I remove a trailing space in Unix?

How do I remove a trailing space in Unix?
Answer
How to remove the leading and trailing spaces in a file?
  1. awk command: $ awk ‘$1=$1’ file Linux 25 Fedora 40 Suse 36 CentOS 50 LinuxMint 15. …
  2. sed command: $ sed ‘s/^ *//;s/ *$//;s/ */ /;’ file Linux 25 Fedora 40 Suse 36 CentOS 50 LinuxMint 15. …
  3. Perl solution: …
  4. Bash solution:
 

Tìm kiếm

Back
Top