Reputation: 24363
I have a TXT file. How can I delete only those lines which only contain numbers. For e.g.:
This has some text.
1300
This has some more text.
1210
This has a text and some numbers. 12
In the sample above, only lines 2 and 4 would be deleted as they are the ones that contain no other symbols besides numbers.
Upvotes: 3
Views: 6115
Reputation: 845
Sed solution (will overwrite the file):
sed -i '/^[[:digit:]]*$/d' filename.TXT
Upvotes: 0
Reputation: 13890
Use grep:
grep -v -E '^[0-9]+$' < source.txt > destination.txt
Upvotes: 2