Ariean
January 28, 2009, 12:41pm
1
I have a file with the below data, i would like to remove the end blank lines with no data. I used the below commands but could not able to succeed, could you please shed some light.
Commands Used:
sed '/^$/d' input.txt > output.txt
grep -v '^$' input.txt > output.txt
input.txt file data:
derek,21345,20000,,,
sam,314343,30000,,,
kevin,989823,40000,,,
,,,
,,,
,,,
Thanks & Regards,
Ariean.
Ikon
January 28, 2009, 12:47pm
2
grep -v '^,,,' input.txt > output.txt
Ariean
January 28, 2009, 1:12pm
3
Thanks for your reply, but what if i have more commas does your command is specific to number of commas in the input file.
Ikon
January 28, 2009, 1:16pm
4
This would assume the first column always had a value.
grep -v '^,.' input.txt > output.txt
Ikon
January 28, 2009, 1:20pm
6
This would remove any line that did not contain any characters or numbers:
grep '[A-Za-z0-9]' input.txt > output.txt