I have a text file with about 8 million rows in it. I need to remove all the rows with a single character in them. For example
This is
the
text file
I
wrote
I want to remove the entire line that has the pronoun "I" on it. Bonus points to the one who can do this on the linux command line.
Here is a try:
awk 'length>1' file
and if you do not want to delete blank lines (with zero characters)
awk 'length!=1' file
And if you have spaces on the lines (that you do not want to count as characters):
awk '{gsub(/[[:space:]]/,"")}length!=1' file
All you need is:
grep '..' file
unless you want to keep empty lines as well in which case it'd be:
grep -v '^.$' file