I have done multiple small blast runs. Now I want to check automatically if all files got completed properly with correct ending.
For example, if I check the ending of a particular file I see:
n85567:Mel_Sanger mitras$ tail /Volumes/ForBlastLactose/output/S5_1FIL_ab.out
Database: SILVA_119_SSURef_tax_silva
Posted date: Jan 6, 2015 11:55 AM
Number of letters in database: 2,241,843,227
Number of sequences in database: 1,583,830
Matrix: blastn matrix 1 -2
Gap Penalties: Existence: 0, Extension: 2.5
So if finished properly the file will have the ending line Gap Penalties: Existence: 0, Extension: 2.5
So now my question is how can I right a script to check all files in a folder for this particular ending and report back with the name of the files if there is mismatch in ending.
I was trying something like:
if [[for f in *.out; tail -1 ${f} == "Gap Penalties: Existence: 0, Extension: 2.5"; then echo "All files are fine"; else echo "Error file:"$f; fi
but being a novice in scripting I am obviously nor getting it right.
Can anybody please help me to do it. Thanks a lot, Mitra
You should not generally expect to come to stackoverflow.com and expect people to write code for you. I am sure you can take it from here.
$ cat endcheck
#!/bin/bash
for i in *.txt;
do
s=$(tail -1 $i)
if [ "$s" != "Gap Penalties: Existence: 0, Extension: 2.5" ]
then
echo File $i does not have the correct ending.
fi
done
pwatson@tmc002 ~/y
$ ./endcheck
File t1.txt does not have the correct ending.