Finding records, skipping records with all spaces
Posted: 06 Jan 2015 01:42
I have a file with some data:
IN_FILE.txt
I would like to remove all records with all spaces (different number of spaces).
I tried:
It works... but I cannot guarantee not to have a record with a space at the end so wrong record could be lost (the same goes for a /B switch - cannot guarantee not to have a space at the beginning of a line).
This:
does not work because empty records have more than one space.
One way could be to add more spaces (10 or more) because there would certanly be more than 10 spaces in 'empty' records. But I would prefer better solution.
At the moment I read complete file and skip 'empty' lines - it works but FINDSTR is much faster.
Can this be done with regular expressions (I am not a regular expression expert)?
Thanks.
Saso
IN_FILE.txt
Code: Select all
some data some data some data some data1
some more data some data some data some data2
some data more moresome data some data some data3
some data some data some data some data4
some data some data data some data some data5
I would like to remove all records with all spaces (different number of spaces).
I tried:
Code: Select all
findstr /E /V /C:" " in_file.txt>out_file.txt
It works... but I cannot guarantee not to have a record with a space at the end so wrong record could be lost (the same goes for a /B switch - cannot guarantee not to have a space at the beginning of a line).
This:
Code: Select all
findstr /B /E /V /C:" " in_file.txt>out_file.txt
does not work because empty records have more than one space.
One way could be to add more spaces (10 or more) because there would certanly be more than 10 spaces in 'empty' records. But I would prefer better solution.
At the moment I read complete file and skip 'empty' lines - it works but FINDSTR is much faster.
Can this be done with regular expressions (I am not a regular expression expert)?
Thanks.
Saso