Script for adding a word in front of all line in a file

Hi

I've one file full of paths of certain files and I want to add some extra file words in front of all the paths. for eg:

i have a file name test.txt which show some details only..

024_hd/044/0344eng.txt
035_bv/222/editor.jpg

here I want to add /usr/people/indiana/ infront of all the files so that i can have like this..

/usr/people/indiana/024_hd/044/0344eng.txt
/usr/people/indiana/035_bv/222/editor.jpg

in a new file..

Can someone help me to create a script for this?

Rath

 
cp filename filename.bk
sed -i 's/^/\/usr\/people\/indiana\//' filename

 
awk -v p="/usr/people/indiana/" 'NF>0 { print p$0}' input_file
 
perl -pe '$_ = "/usr/people/indiana/".$_' input

oh its too simple..

awk '{print "/usr/people/indiana/"$1}' inputfile >> outputfile
1 Like