LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Help: Sed trick (https://www.linuxquestions.org/questions/linux-general-1/help-sed-trick-741180/)

the_gripmaster 07-19-2009 09:18 AM

Help: Sed trick
 
I have a sample file:

Code:

         
AA019  120    988    102
BB 12  120    988    102
CC022  120    988    102
DD 25  120    988    102
EE    120    988    102
FF 21  120    988    102
GG    120    988    102
HH011  120    988    102
II    120    988    102
JJ 54  120    988    102
            ^
        more 4 space character in this column

I need to insert 4 spaces at the position indicated of every line. How can this be done?

jschiwal 07-19-2009 09:29 AM

You need four spaces inserted after the 12th character?

Code:

sed 's/\(.\{12\}\)\(.*\)/\1    \2/' sample.txt

the_gripmaster 07-19-2009 10:03 AM

Quote:

Originally Posted by jschiwal (Post 3612721)
You need four spaces inserted after the 12th character?

Code:

sed -e 's/\(.\{12\}\)\(.*\)/\1    \2/' sample.txt

Yup, you got it right. Thanks a lot.


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