I have code of something like the following.
我有类似以下的代码。
awk '{ print $1, $2}' file |
while IFS= read A B
do
echo $A
if [ "$B" -eq "16" ];
then
grep -A 1 $A $1 | python unreverse.py
else
grep -A 1 $A
fi
done
where the awk command outputs a string and a number for each line in file. I don't quite understand how to get the while loop to work, however. It is not splitting the line properly because B is empty and I get "integer expression expected".
其中awk命令为文件中的每一行输出一个字符串和一个数字。但是,我不太明白如何让while循环工作。它没有正确分割线,因为B是空的,我得到“预期的整数表达式”。
1 个解决方案
#1
2
You are essentially undefining IFS with IFS= read A B
, so word splitting does not occur and all the input is captured into $A. Simply remove IFS=
, or use IFS=" "
, and you should be satisfied
您基本上是在IFS =读取A B时取消定义IFS,因此不会发生分词,并且所有输入都被捕获到$ A中。只需删除IFS =,或使用IFS =“”,您应该感到满意
#1
2
You are essentially undefining IFS with IFS= read A B
, so word splitting does not occur and all the input is captured into $A. Simply remove IFS=
, or use IFS=" "
, and you should be satisfied
您基本上是在IFS =读取A B时取消定义IFS,因此不会发生分词,并且所有输入都被捕获到$ A中。只需删除IFS =,或使用IFS =“”,您应该感到满意