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

Inserting text in the middle of a file on every line

Status
Not open for further replies.

lbzh

Programmer
Aug 7, 2004
25
US
I have a Unix scripting question,I have a file such as below:
1234ABCDE KLDS
2334KLVDE ABdd
9832BDKLE TMDA


I would like to insert the string "HERE" in position 5 in every line in the file and the rest of the characters in each line move over
resulting in the following:
1234HEREABCDE KLDS
2334HEREKLVDE ABdd
9832HEREBDKLE TMDA
......
Note: Each line could move 2 or more successive blanks somewhere on the line which I would like to maintain.
any ideas on what method to approach this.

Thanks
 
Something like this ?
sed 's!^\(....\)!\1HERE!' /path/to/input >output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top