Variables 在bash中使用for循环中的变量
简单问题: 从编号列表中获取编号(i);然后用每个数字做某事Variables 在bash中使用for循环中的变量,variables,for-loop,Variables,For Loop,简单问题: 从编号列表中获取编号(i);然后用每个数字做某事 for i in list_of_number;do cat file|head -$(($i+1))|tail -1;done 这似乎是对的,但实际上不起作用。这里有什么问题? thx这样做会将编号的列表视为一个字符串;我假设这是一个包含要循环的数字列表的文件 请尝试: for i in `cat list_of_number`;do cat file|head -$(($i+1))|tail -1;done 对于“猫列表”中的“
for i in list_of_number;do cat file|head -$(($i+1))|tail -1;done
这似乎是对的,但实际上不起作用。这里有什么问题?
thx这样做会将编号的列表视为一个字符串;我假设这是一个包含要循环的数字列表的文件 请尝试: for i in `cat list_of_number`;do cat file|head -$(($i+1))|tail -1;done 对于“猫列表”中的“猫编号”;做cat文件|头-$($i+1))|尾-1;完成
别担心,我总是犯这样的错误。Bash可能是相当不可原谅的。