help-bash
[Top][All Lists]
Advanced

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

Re: sed: Invalid content of \{\}


From: Eli Schwartz
Subject: Re: sed: Invalid content of \{\}
Date: Sun, 18 Apr 2021 12:37:02 -0400

On 4/18/21 12:18 PM, michael-franzese@gmx.com wrote:
> 
> 
> Am trying to capture tho string within {}, but am getting
> 
> sed: -e expression #1, char 19: Invalid content of \{\}
> sed: -e expression #1, char 19: Invalid content of \{\}
> sed: -e expression #1, char 19: Invalid content of \{\}
> 
> 
> a="{12..30..5}"
> fa=`echo $a | sed 's/.*(\{.*\}).*/\1/g'`


Not really clear what you're trying to do here, but this error comes
from sed, not bash...

The sed message could be fixed by passing the non-standard -r option to
sed, after which sed prints back the original value of $a without
modification.

There's a couple of other bad mistakes here, such as using deprecated
and terrible backtick

fa=`cmd`

instead of

fa=$(cmd)

And the fact that whichever actual command you intend to run and filter
with sed, might contain IFS characters, so you should be quoting

echo "$a"

It's impossible to tell without the truthful context of your question,
whether there are other problems in your sed (or which problems).

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]