我有一个目录,其中包含该月的每日CD。我需要在所有cd中搜索ph值列表,并将结果写入每种模式的单个文件中。
目前,我正在对包含每月CD的目录中的每个ph编号手动使用以下命令,并将每个编号的结果写入单个文件。
grep -rn 111222333 /dir-containing-new-indivdual-logs/111222333.csv
我尝试添加grep -f
选项来指定搜索列表,但没有运气,因为我整个命令的语法是错误的。
如果您希望继续使用grep,请考虑以下循环
nums=/path/to/the/file_with_numbers_one_per_line
wdir=/path/to/dir/where/records2searchIn/located
rdir=/path/to/dir/to/put/results
for anum in $(cat ${nums}); do
grep -nr "${anum}" ${wdir} > ${rdir}/result_file_for_${anum};
done
这会为列表中的每个数字进行grepping并保存单个结果
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句