Ur code works well.....
but as I want to run this code on multiple files....i need to save this printed data of each file in their corresponding output file for further analyses. Iam using the following code :
But the output file is completely blank...without any data....However, the code is giving the desired output if data is not transfered to the new output file.
No need for 'paste'; that tool is used to merge lines. I assume the file liist has the filenames to be processed, one per line, right?
The redirection operator you have there, '>' will truncate the output file on every iteration of strings. Use '>>' instead to append; or do the redirection at the end:
while read line; do
while read aa ; do
awk '$2=="'$aa'" && !($1==$3)' $line
done < strings > ${line}new
done < liist
You can get rid of the outer shell loop and process all files with awk, and print into the file from awk. Much more efficient. Like this:
while read aa ; do
awk '$2=="'$aa'" && !($1==$3){print >> FILENAME"new"}' `cat liist`
done < strings
I am facing one more problem in this......
In the above case, lets say the "strings" list contains 20 strings which are scanned in the original file. If in original file, any three random strings are missing, the immediate next will be printed (i.e, out of 20, only 17 are printed continuously) but I dont want to skip the whole row...instead of that i wanna print "Absent" in each column of that missing row....