我怎样才能让猫壳循环?
问题描述:
我是新来的Python和外壳,我需要为循环这句话我怎样才能让猫壳循环?
cat $input | sst print-vectors $model_bin_file > tors.txt
这$input
这里是一个文件包含one line
,我怎样才能使它循环为一个语句文件中的所有行?该文件我有一个包含名为out.txt
所有行我试着写
for i in $(cat $out.txt | sst print-tors $model_bin_file)
do
i> tors.txt
done
我得到i: not found
答
使用适当的循环,看到你为什么DontReadLinesWithFor以及如何避免无用的使用-的-cat
#!/bin/bash
while IFS= read -r line
do
# do whatever you want to do with the line read stored as "$line"
echo "$line" | ass print-tors "$model_bin_file"
done <"out.txt" >> "tors.txt"
对于'vectors.txt'文件中的每一行,你想运行'fasttext print-vectors $ model_bin_file'? – Inian
请参考下面的我的更新,我想你需要用'>>'附加运算符来追加行到'vectors.txt' – Inian
对于'fasttext print-vectors $ model_bin_file',行的内容是否重要?或者你只是想运行'fasttext print-vectors $ model_bin_file' N次,其中N = out.txt文件中的行数? – sameerkn