SED giving problem when trying to substitute the 10th field

March 26, 2012 at 01:52:33
Specs: UNIX-solaris
sed 's/\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)\(...\)\(.\)\(..\)/\1-\2-\3-\4.\5.\6.\7|\8|\9|/' san.txt

this command works fine for this data

20030910114500000000
20030910020000000000


but the same is not the case when i try to add 10 field

sed 's/\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)\(...\)\(.\)\(.\)\(.\)/\1-\2-\3-\4.\5.\6.\7|\8|\9|\10/' san.txt

it is giving me error as Sed command grabled

Thanks in advance


See More: SED giving problem when trying to substitute the 10th field

Report •

#1
March 26, 2012 at 09:05:40
You have run into a limitation of legacy sed. Since you are using Solaris, probably you have the /usr/xpg4/bin directory which contains copies of POSIX complient commands:

/usr/xpg4/bin/sed 's/\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)\(...\)\(.\)\(.\)\(.\
)/\1-\2-\3-\4.\5.\6.\7|\8|\9|\1\0/' san.txt


Report •

#2
March 26, 2012 at 23:30:58
Thank you for the response,

this doesn't solve my problem, for the tenth field it uses concat of 1st field and a 0

appreciate your Quick Response



Report •
Related Solutions


Ask Question