I'm using Bash and \\+
works with grep
but not with sed
.
For example if I do
echo "abbbbc"| sed -e s/ab\\+c/def/
I obtain this result : abbbbc
I tried with '
or with "
around s/ab\\+c/def/
, I obtain the same result.
but if I replace \\+
with *
, I obtain : def
I have to change >Atab_TR4682|c0_g1_i1|m.14206
into Atab
If I do echo ">Atab_TR4682|c0_g1_i1|m.14206" | sed -e "s/>*\\([[:alpha:]]\\\*)_.\*/\1/g"
I obtain Atab_TR4682|c0_g1
probably because *
could also be used for 0 iteration, but if I replace *
by \\+
it doesn't work at all..
Does anyone have an explanation?
sed -r
to use extended regular expressions perhaps? – DopeGhoti Mar 24 '17 at 17:34\
before the+
– don_crissti Mar 24 '17 at 17:35sed
already aliased tosed -r
(orsed -E
) maybe? That would turn\+
into+
and vice versa – steeldriver Mar 24 '17 at 17:46man sed
and there was no-E
switch, but there was-r, --regexp-extended
. What I meant about the quotes, @don_crissti, is that if not in strong quotes,bash
will catch the escape before it'll even get tosed
. – DopeGhoti Mar 24 '17 at 17:56'
) are what I was mentioning. – DopeGhoti Mar 24 '17 at 18:00sed --version
show at your end ? – Mar 24 '17 at 18:03