1833875 Members
3302 Online
110063 Solutions
New Discussion

help with script

 
George_216
New Member

help with script

Im trying to check a file with 1000s of lines all the columns and rows should be

0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00


Is there any way to run a script on this file and report any lines with any column not equal to "0.00000000E+00"

Any help would be appreciated. attached is a sample text file.
5 REPLIES 5
Bharat Katkar
Honored Contributor

Re: help with script

Hi,
See if this works for you:

# cat filename | xargs | grep -v "0.00000000E+00"

Regards,

You need to know a lot to actually know how little you know
George_216
New Member

Re: help with script

im sorry, it didn,t help
Sudeesh
Respected Contributor

Re: help with script

grep -v "0.00000000E+00"
will work for you. You can write a script like this:

for files in /home/testdir/*
do
echo $files
grep -v "0.00000000E+00" $files
echo "****************************"
done



Sudeesh
The most predictable thing in life is its unpredictability
George_216
New Member

Re: help with script

your solutions will exclude all lines with 0.00000000E+00.


for example It will exclude this line as well:
0.00000000E+00 4444444444 0.00000000E+00


Stuart Browne
Honored Contributor

Re: help with script

If every line will have 5 entries on it (like in the example), then a slight expansion on the above suggestions:

grep -v "0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00" file

As this will only exclude lines which are all 0'd.

Now, that being said, if there is a variable number of entries per line, then a quick awk:

awk '{ count = 1;while (count < NF) { if ($count != "0.00000000E+00") { print; next } ; count++ } }' < file

Anyway, just some ideas. ;)

Note: with the above 'awk', if you want to only print out the different actual fields (instead of the entire line), change the 'print; next' to 'printf( "%s\n", $count)' .
One long-haired git at your service...