S
S
Sergey Kolpakov2016-11-09 16:19:44
linux
Sergey Kolpakov, 2016-11-09 16:19:44

How to force sed to search not from the beginning of a line with '*' quantifier?

Given:
# echo 'abcd' | sed -e 's/a*//'
bcd (as expected)
# echo 'abcd' | sed -e 's/b*//'
abcd (why?!!)
How to rewrite the expression to get acd in the second case?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Valle, 2016-11-09
@Zolushok

~$ echo 'abcd' | sed -e 's/b*//
g'acd

L
Leonid, 2016-11-09
@zzevaka

% echo 'abcd' | sed -E 's/b+//'
acd
% echo 'abcd' | tr -db
acd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question