mardi 22 mars 2016

sed to Find and Replace chacters between two strings

I have a pipe delimited file where some values/records in one of the columns contain pipes in the value itself making it appear as though there are more columns than there actually are - Notice how "column 8" (bolded) has pipes in the middle. This should actually display as "|col u lm n8|" with spaces in place of the pipes.


I need to replace these pipe's within column8 with spaces.

Good thing is that the data in column7 and column9 (|2016) is the same across the file so I'm able to do a sed such as this

sed 's/|/ /7g;s/.\(|2016\)/|\1/' 

However that will change all pipes after the 7th pipe to the end of the line. My question is how can I get it to change all pipes to spaces after the 7th pipe but up to the "|2016" column ?

Thank you

sed to Find and Replace chacters between two strings

Aucun commentaire:

Enregistrer un commentaire