-1

My input file is:

Employee
e_id e_name
100 abc
101 xyz
102 pqr


Salary
e_id e_salary
100 12345
101 67890


Dependents
e_id depp1 depp2
100 qwer tyui
102 asdf ghjkl

I want the output line by line as shown below:

E100abc
E101xyz
E102pqr
S10012345
S10167890
D100qwertyui
D102asdfghjkl

In output there should be starting character which will indicate from which data group this line of data gets fetched.

0
for file in Employee Salary Dependents; do
    prefix="${file:0:1}" # First character of the filename
    sed "1,2d;s/ //;s/^/$prefix/" "$file"
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.