我有几个文件夹作为bash脚本查找文件夹中
Main/
/a
/b
/c
..
我不得不从各自每个文件夹通过输入文件abc1.txt
,abc2.txt
作为输入文件到我的Python程序。 脚本现在的问题是,
for i in `cat file.list`
do
echo $i
cd $i
#works on the assumption that there is only one .txt file
inputfile=`ls | grep .txt`
echo $inputfile
python2.7 ../getDOC.py $inputfile
sleep 10
cd ..
done
echo "Script executed successfully"
所以我想正确不管.txt文件数量的脚本工作。
任何人都可以让我知道如果shell中有任何内置命令来获取正确的.txt文件,以防万一多个.txt文件?
你的文件'file.list'和'.txt'文件之间有什么关系?何时使用'$ i'变量除了'echo $ i'行? –
您的.txt文件中必须传递给pyhton脚本的唯一内容是什么?如果它的文件名不能找到。 -name file.txt – Chipmunk
file.list包含其中的所有文件夹。 .txt文件位于所有文件夹中。 $ i变量用于cd到该文件夹中,不知何故它在脚本中被省略。 – veepsk