Bash-使用通配符重定向 [英] Bash - Redirection with wildcards
本文介绍了Bash-使用通配符重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在测试使用通配符进行重定向.像这样:
I'm testing to do redirection with wildcards. Something like:
./TEST* < ./INPUT* > OUTPUT
有人有什么建议吗?谢谢.
Anyone have any recommendations? Thanks.
推荐答案
有一个名为TEST *的程序,必须将各种重定向转换为称为INPUT *的程序,但问题是有很多TEST程序,并且它们都有不同的编号,例如TEST678.我想做的是将所有随机INPUT文件推入所有TEST程序中.
There is a program called TEST* that has to get various redirection into into called INPUT*, but the thing is there are many TEST programs and they all have a different number, e.g. TEST678. What I'm trying to do is push all the random INPUT files into all the all TEST programs.
您可以写:
for program in TEST* # e.g., program == 'TEST678'
do
suffix="${program#TEST}" # e.g., suffix == '678'
input="INPUT$suffix" # e.g., input == 'INPUT678'
"./$program" < "$input" # e.g., run './TEST678 < INPUT678'
done > OUTPUT
这篇关于Bash-使用通配符重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文