Bash 我怎样才能在猫壳里做环呢?
我不熟悉python和shell,我需要在这个语句上进行for循环Bash 我怎样才能在猫壳里做环呢?,bash,shell,Bash,Shell,我不熟悉python和shell,我需要在这个语句上进行for循环 cat $input | sst print-vectors $model_bin_file > tors.txt 哪个$input这里有一个文件包含一行,如何使它在一条语句中循环文件中的所有行?我拥有的文件包含所有名为out.txt的行 我试着写作 for i in $(cat $out.txt | sst print-tors $model_bin_file) do i> tors.txt done 我得
cat $input | sst print-vectors $model_bin_file > tors.txt
哪个$input
这里有一个文件包含一行
,如何使它在一条语句中循环文件中的所有行?我拥有的文件包含所有名为out.txt的行
我试着写作
for i in $(cat $out.txt | sst print-tors $model_bin_file)
do
i> tors.txt
done
我得到了i:notfound
使用一个合适的循环,看看你为什么和如何避免无用的使用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"
#/bin/bash
而IFS=读取-r行
做
#对存储为“$line”的读取行执行任何操作
echo“$line”| ass print tors“$model_bin_file”
完成>“tors.txt”
对于文件vectors.txt
中的每一行,您想运行fasttext打印vectors$model\u bin_文件
?请参阅下面的更新,我认为您需要>
append操作符,将行追加到vectors.txt
行的内容对fasttext打印vectors$model\u bin_文件
重要吗?或者只是想运行fasttext打印向量$model_bin_file
N次,其中N=out.txt文件中的行数?是的,我需要为out.txt simplyMeans运行此命令N次?它仍在工作,我会知道它是否会成功完成后,然后我会告诉你you@downvoter你能解释一下你为什么这么做吗?背后的理由是什么?