Hi all,
I have some data in the form of
adc|nvhs|nahssn|njadnk|nkfds
in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like
adc|nvhs|nahssn||||njadnk|nkfds
Thanks,
Firestar.
sed 's/[^|]*|[^|]*|[^|]*|/&|||/'
Thank you so much for the quick reply ......
Here the solution which you gave works fine for me.... but i am sorry to cofuse you but my Data has not eaxctly 4 feilds it has ogt 74 feilds and i want to appeend the "|||" after 49th feild.......
thanks once again for the quick reply
sed 's/'$(for i in $(seq 1 49); do printf "%s" '[^|]*|'; done)'/&|||/'
1 Like
firestar:
Thank you so much for the quick reply ......
Here the solution which you gave works fine for me.... but i am sorry to cofuse you but my Data has not eaxctly 4 feilds it has ogt 74 feilds and i want to appeend the "|||" after 49th feild.......
thanks once again for the quick reply
to replace at the 49th field/occurence of pipe symbol ( | )
sed 's/|/|||/49' inputfile
2 Likes