我做过多次小爆炸。现在,我想要自动检查是否所有文件已正确完成与正确的结尾。
例如,如果我检查特定文件的结尾,我会看到:
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因此,如果完成正确,该文件将有结束行Gap Penalties: Existence: 0, Extension: 2.5
因此,现在我的问题是,我如何才能正确的脚本检查文件夹中的所有文件为这个特定的结尾,并报告回与文件的名称,如果有不匹配的结尾。
我试过这样的方法:
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 但是,作为一个脚本新手,我显然还没有把它做好。
有人能帮我做一下吗。非常感谢,米特拉
发布于 2015-07-22 23:00:26
一般情况下,您不应该期望使用stackoverflow.com并期望人们为您编写代码。我相信你可以从这里接手。
$ 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.https://stackoverflow.com/questions/31541844
复制相似问题