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

Re: Including ' in a sed command



On 8/7/25 07:17 PM, 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.

Tim.

Have you considered using '-f scriptfile'?

Your regex goes in the file and completely eliminates issues of collisions with shell metacharacters.

Bob


Reply to: