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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing the first occuence in a file using sed

Status
Not open for further replies.

RJSHA1

Programmer
Apr 12, 2001
66
0
0
GB
Hi there,
I have a file with the following layout :-

Header
Data
Trailer

I want to append a sort code to the hader so that the file looks like this

Header123456
Data
Trailer

I have tried sed 's/$/123456/' file1 > file2

but I get

Header123456
Data123456
Trailer123456

What am I doing wrong


Thanks Bob....

 
Try
Code:
awk 'NR==1 {print $(0)123456;next} {print}' file1 > file2
Greg.
 
Try something like this:
Code:
sed '1s/$/123456/' file1 > file2

Hope This Help
PH.
 
Hi guys,
Both solutions work. Thanks for your help. I have one other question, will the end of line character still be left on the 1st line


Once again thanks for the help


Regards bob..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top