Insert character by using sed/awk
Hi Guys,
I need a help that how can i insert character/digit in line by line. I want to add 3 numeric before 34th character, 3 character after 52, 1 character after 59th and 1 character after 75th. Can you guide me how i can write a script/command by using sed/awk. Thanks Manish |
Here are a couple of nice sites on sed.
http://sed.sourceforge.net/sed1line.txt http://www.grymoire.com/Unix/Sed.html#uh-8 Here are a couple of examples to get you started. # Add a word after the fifth character sed 's/./&mudd/5' file.txt # Add a word before the fifth character sed 's/./mudd&/5' file.txt |
First, do this:
Code:
man sed But read those two man pages. Then start with a simpler problem than your final one. Dink with it until it works. Then add complexity until you have what you want. If, along the way, you have a detailed question about why what you wrote doesn't work, this is a really good way to ask about it. But post all the details, including your sed or awk command, your input data, your output data, and any error message. Good luck. |
Thanks for the prompt reply.
I managed to resolved by awk command with substr function. Thanks once again. Manish |
All times are GMT -5. The time now is 01:43 AM. |