Need help badly [message #57579] |
Tue, 24 June 2003 09:22 |
sidd
Messages: 130 Registered: May 2003
|
Senior Member |
|
|
I need to append a "##" for every row that starts with a number or numeric filed, and i need to write a script in korn, say i have a file like this
1212, dasfads, jkdfdas
kdfafadsf
2223, dfjaksd, dfjadsf,kjdfkad
5454, kdfjaksd, 343,mdsfas
adfasd
3434, dfadasdf,asdfas, adfas.
So i need to append a "##" sign for ever row that start with a numberic filed, how do i do that
|
|
|
Re: Need help badly [message #57581 is a reply to message #57579] |
Tue, 24 June 2003 11:20 |
Sanjay
Messages: 236 Registered: July 2000
|
Senior Member |
|
|
sed 's|^([[0-9]])|##1|'
First try it inside vi. Worked for me. Then put it in the korn shell script.
Good luck.
|
|
|
|
|
Re: Need help badly Explain your cmd buddy, [message #57643 is a reply to message #57587] |
Thu, 26 June 2003 13:14 |
Sanjay
Messages: 236 Registered: July 2000
|
Senior Member |
|
|
sed 's|^([[0-9]])|##1|'
means...
1. s=In SED, use substitute
2. |^([[0-9]])|=find the beginning of line with number
3. |##1|=insert ## there.
Your input is
1212, dasfads, jkdfdas
kdfafadsf
2223, dfjaksd, dfjadsf,kjdfkad
5454, kdfjaksd, 343,mdsfas
adfasd
dasdf,asdfas, adfas.
Output is
##1212, dasfads, jkdfdas
kdfafadsf
##2223, dfjaksd, dfjadsf,kjdfkad
##5454, kdfjaksd, 343,mdsfas
adfasd
dasdf,asdfas, adfas.
|
|
|