I am having two file naming Extra_info and Class_info
Class_info contains data :
stuId stuName stuClass
S01 Josh First
S02 harsh First
S03 Roop Second
S04 Kali Third
Extra_info contains extra information about student like
stuId stuCity stuEmail stuPhone
S01 Poh [email protected] 1234567890
I am getting result from both files using grep for stuId and displaying the result as:
res1=`grep $stuId $locDir/Class_info`
res2=`grep $stuId $locDir/Extra_info|cut -d" " -f2-`
## also I tried res2=`grep $stuId $locDir/Extra_info|awk '{$1="" ; print $0}'`
echo $res1 $res2
Instead of displaying:
S01 jagdeep First Sirsa [email protected] 1234567890
It is displaying:
Sirsa [email protected] 1234567890
As I could think at the time of echo the variable res2 is nullifying result from res1.
Please, suggest the possible reason for this and please provide solution for the same.
zsh, same result: if I store the result of 2 consecutivegrepin two variables andechothem, the first is not printed. If I onlyechothe first, it works. If the first is assigned the result of alsinstead of agrep, it works. So the problem could be related togrepoutputs? I don't understand why.zshon my system as expected, ie. the results of bothgreps are printed.