[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Including ' in a sed command



On Fri, 8 Aug 2025, Jonathan Dowland wrote:

If you can guarantee that another spare character will not appear in your input, doing something like this (with @ as the spare) can help to avoid the layers-of-escapes problem.

	? | tr \" @ | sed ? | tr @ \"

It's a simple hack, but sometimes they're just the thing. If you are going to strip out all the tabs anyway, for example, you could do that first, and have tab as a spare.


Ha, brilliant!

In my case I can just strip out the quotes completely I think with tr -d "\"',"

Maybe even the spaces too and have 's/.*\$ref:\(.*\)/\1/'

I need to check but I think it's only a trailing comma that I need to worry about and all the filenames are "sane" with no spaces or commas in them.

Tim.


Reply to: