[Nottingham] Howto delete chars from midway into lines of text?

TJ linux at tjworld.net
Thu May 6 12:37:13 UTC 2010


On Thu, 2010-05-06 at 13:17 +0100, Martin wrote:
> Folks,
> 
> Hopefully an easy answer for this one:
> 
> Given a ".csv" file where all the items are all delimited as text, how
> can I delete the nth and nth+1 quotes to turn one column into non-text?
> 
> 
> Preferably via sed or whatever...

sed 's/\("\)\([^",]*\)\("\)/\2/4' test.csv

Replace the final '4' with N.

It is somewhat convoluted because sed regular expressions don't support
non-greedy operators, they only use 'greedy' operators so we can't do
something like this:

's/\("\)\(.*?\)\("\)/\2/4'




More information about the Nottingham mailing list