LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Inserting spaces using SED/AWK ? (https://www.linuxquestions.org/questions/programming-9/inserting-spaces-using-sed-awk-487915/)

aravindts 09-29-2006 02:45 AM

Inserting spaces using SED/AWK ?
 
Hi All,

I have a requirement to insert two spaces in a file.
The file is of size 350 mb.

The file has 182 characters in each line and i need to insert spaces in positions 174 and 175.The rest of the file content should not be altered .

After inserting the spaces, there should be 184 characters in each line, including spaces.

I am new to unix programming.Please help.

Thanks in advance,
Aravind

konsolebox 09-29-2006 03:07 AM

hello aravindts. please try this command.

# cat FILE | sed -i s/"^.\{173\}"/"& "/ > OUTPUTFILE

or to modify directly

# sed -i s/"^.\{173\}"/"& "/ FILE

aravindts 09-29-2006 04:22 AM

thnx Konsolebox,


i tried your way it says illegal option -i
any other way you know ??

konsolebox 09-29-2006 05:04 AM

perhaps you're using an old version of sed sorry about my first statement. it should be

# cat FILE | sed s/"^.\{173\}"/"& "/ > OUTPUTFILE

aravindts 09-29-2006 05:28 AM

Konsolebox,(I would love to know your real name :-) )

This works.

Thank you very much.

Regards,
Aravind


All times are GMT -5. The time now is 04:50 PM.