echo中的可变位置正在改变结果

时间:2013-12-05 07:31:36

标签: bash unix awk grep echo

我使用grep从两个文件中获取结果,并将结果分别存储在两个变量中。 如果我改变变量的位置,那么我在那时回显两个变量的输出,然后结果发生变化。 下面用示例

解释该场景
i=123
res1=`grep S$i $NamesFile` 
res2=`grep S$i $FeeInformation|awk '{$1="" ; print $0}'` 
echo "$res1 $res2" ## this prints the value from both variable separated by space 
echo "$res2 $res1" ## in this the variable two override the output of variable one

问题只发生在我的终端我在其他机器上测试它工作正常,甚至在我的终端它工作到昨天,不知道发生了什么变化影响了这个

NameFile包含类似Student_id的信息Name_of_student Mobile_No Location Email_id

FeeInformation文件包含值Student_id Class Fee Admission_type(DOnation / Free)

请建议可能的原因。 提前致谢

1 个答案:

答案 0 :(得分:0)

换行符字符\ r \ n导致了问题

相关问题