I have a input file with below data:
DH1|ABC|DEF
DL1|abc|pqr
DL2|mno|rst
DH2|XYZ|MNO
DL1|def|ghiThe output file data must be:
DH1|ABC|DEF|DL1|abc|pqr
DH1|ABC|DEF|DL2|mno|rst
DH2|XYZ|MNO|DL1|def|ghiEach DH needs to be appended with its corresponding DL's.Can anyone help me out with this?
It looks to me like you are interested in someone doing your homework. I'll get you started. First, this link shows you how to read a file line by line:
http://www.computing.net/answers/un...
Next, the solution to your problem is lines starting with DL is your base line. It changes every time a new DL line appears. With any other line, to the base line, append a pipe symbol and that line onto the base line and print it out.
The hard part is determining if the line starts with DL. This if statement does that:
if echo $line| grep "^DH" > /dev/null then DHbase=$line fi
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |