Append variable string(s) at end of each line
Hi
Thanks in advance and appreciate any inputs.
Please see the examples for better understanding of my issue
#file1 Contents
1
2
3
#file2 COntents
1,E1,F1,G1,E2,F2,G2
2,H1,I1,J1,H2,I2,J2
3,K1,L1,M1,K2,L2,M2
create file3
cat file1.txt | grep "1" | sed 's/$/,E1,F1,G1,E2,F2,G2/'
output is
1,E1,F1,G1,E2,F2,G2 (correct)
But if I try to do it using
holder="1"
string=",E1,F1,G1,E2,F2,G2"
cat file1.txt | grep "$holder" | sed 's/$/$string/'
OUtput is:
1,$string ( NOT Correct)
Whereas I was hoping to get 1,E1,F1,G1,E2,F2,G2
Sorry for long post. Thanks for your time
Last edited by schaganti; 10-19-2007 at 11:40 AM.
Reason: Clarifying with example
|