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

Re: Including ' in a sed command



On 8/8/25 12:17, Tim Woodall wrote:
iHi All,

(Typed, rather than cut/pasted so apologies if there's a typo)

This is part of a sed command in a bash script.

sed 's/["'"'"']//'

This matches " or '. It works.

But it's 'unreadable' and almost impossible to find the typo if it's wrong.

Is there a better way of writing it? the obvious '["\']' doesn't work.

These work with bash for me (bash). I usually prefer to enclose in dq since I often have shell vars in the rule:
	sed "s/[\"']//"
	sed $"s/["\']//"

Though maybe your real requirement is more complex than revealed?

Tim.

--
Eyal at Home (eyal@eyal.emu.id.au)


Reply to: