Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

command to duplicate lines

Status
Not open for further replies.

TheDash

MIS
Mar 25, 2004
171
US
Hello members, I have a text file and I am looking for a way to duplicate lines in it. Above every line, a duplicate line should be inserted with comment in the front as shown below. Any help will be appreciated. Can a sed or awk command do the trick. Thank you in advance.

x
y
z

--x
x
--y
y
--z
z
 
[tt]awk '{print "--" $0; print}'[/tt]

should do it.

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top