3

Hi I want to be able to edit the list of name like this using either AWK or SED.

Sample input list file:

john
paul
rose
lily

Desired output:

I am john of earth;
I am paul of earth;
I am rose of earth;
I am lily of earth;

I want the semicolons at the end too. i don't want to use shell scripts of for loops.

2 Answers 2

4

With awk you can use print:

awk '{ print "I am", $1, "of earth;" }' list

or printf:

awk '{ printf("I am %s of earth;\n", $1); }' list
0
3

Using sed:

$ sed 's/.*/I am & of earth;/' file.txt 
I am john of earth;
I am paul of earth;
I am rose of earth;
I am lily of earth;
0

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.