Earlier I created the below question, unfortunately it has been closed.
How to append the path in the given file list
I made a mistake in that question, Now I have corrected it in this question.
Due to that I have created a new post.
I'm looking for a bash/shell script approach.
My file list consists of different types of file names.
I want to append the path at the beginning of each line in the file list.
file_list.txt
contents:
pkg/arc/PM/MW/aaa.ctf
bbb.lst
ccc.lst
pkg/arc/scr/mass/dim/config/hsc.c.in
pkg/arc/PM/MW/ddd.pkg
eee.lst
I want to append the specific path of each file in the file list.
Following output should be updated on the same file_list.txt
Example output:
d:est/build/rdb/pkg/arc/PM/MW/aaa.ctf
d:est/build/bbb.lst
d:est/build/ccc.lst
d:est/build/mass/dim/config/hsc.c.in
d:est/build/rdb/pkg/arc/PM/MW/ddd.pkg
d:est/build/eee.lst
My Code: I tried the following command to modify and update the path:
SCRDIR="d:est/build/"
PMDIR="d:est/build/rdb/pkg/arc/PM"
sed -i -e "s|^|${SCRDIR}|" file_list.txt
sed -i "s#.*scr#$SCRDIR#g" file_list.txt
sed -i "s#.*PM#$PMDIR#g" file_list.txt
By using above three command I can achieve the result. But is there any other way or approach to get the same output.