| [SOLVED] Deleting hard returns problem I have a list of web addresses in a text file on my Linux server. Users can edit that file of addresses across the network from Windows machines. I have some scripts to analyze the file and I need to remove empty lines, hard returns. Such as: lenovo.com
dell.com
hp.com
Becoming:
lenovo.com
dell.com
hp.com
If the file is created and edited ONLY in Linux, this has always worked fine: Code: grep -iv "^$" /path/to/file
However, if the file has been edited by a Windows machine somewhere on the network, then the emtpy lines aren't removed. I've done some searching and tried this line: Code: perl -pi -e 'tr/[\012\015]//d' >
But it works a little too well. It strips line returns and hard returns so that the output is Code: lenovo.com.dell.com.hp.com
When I need to have
lenovo.com
dell.com
hp.com
Anybody have the answer for me? I've also read about the dos2unix command but that's not an option to use in this case.
Thank you for suggestions. |