commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Remove empty lines additionally:
tr -s ' \t\n' <1.txt >2.txt
tr -s '[:space:]' <1.txt >2.txt
To "clean perfectly" a text or code file, You can combine this command with
while read l; do echo -e "$l"; done <1.txt >2.txt
(= remove all leading and trailing spaces or tabs from all lines of a text file)
There are 6 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.