Skip to main content
deleted 5 characters in body
Source Link
Learner
  • 297
  • 1
  • 4
  • 10

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass 
S01    jagdeepJosh  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like

stuId stuCity stuEmail         stuPhone
S01    SirsaPoh  [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.

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass 
S01    jagdeep  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like

stuId stuCity stuEmail         stuPhone
S01    Sirsa  [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.

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.

added 6 characters in body
Source Link
glenn jackman
  • 88.5k
  • 16
  • 124
  • 179

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass 
S01    jagdeep  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like

stuId stuCity stuEmail         stuPhone
S01    Sirsa  [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

     S01 jagdeep First Sirsa  [email protected]  1234567890

It is displaying: Sirsa [email protected] 1234567890

     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.

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass 
S01    jagdeep  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like

stuId stuCity stuEmail         stuPhone
S01    Sirsa  [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.

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass 
S01    jagdeep  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like

stuId stuCity stuEmail         stuPhone
S01    Sirsa  [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.

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass S01 jagdeep First S02 harsh First S03 Roop Second S04 Kali Third

stuId stuName stuClass 
S01    jagdeep  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like stuId stuCity stuEmail stuPhone S01 Sirsa [email protected] 1234567890

stuId stuCity stuEmail         stuPhone
S01    Sirsa  [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.

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass S01 jagdeep First S02 harsh First S03 Roop Second S04 Kali Third

Extra_info contains extra information about student like stuId stuCity stuEmail stuPhone S01 Sirsa [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.

I am having two file naming Extra_info and Class_info

Class_info contains data :

stuId stuName stuClass 
S01    jagdeep  First
S02    harsh    First
S03    Roop     Second
S04    Kali     Third

Extra_info contains extra information about student like

stuId stuCity stuEmail         stuPhone
S01    Sirsa  [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.

Tweeted twitter.com/#!/StackUnix/status/436178145960816640
Source Link
Learner
  • 297
  • 1
  • 4
  • 10
Loading