Given that
echo -e 'one.onetwo' | sed -n 's/\(.*\)\.\1/x/p'
prints xtwo, why does the following print onextwo?
echo -e 'one.two' | sed -n 's/\(.*\)\.\1/x/p'
Given that
echo -e 'one.onetwo' | sed -n 's/\(.*\)\.\1/x/p'
prints xtwo, why does the following print onextwo?
echo -e 'one.two' | sed -n 's/\(.*\)\.\1/x/p'
Copyright © 2021 Jogjafile Inc.
The're only one place where
\.can match: the dot betweenoneandtwo. As there's no non-empty substring repeating before and after the dot, the.*matches the empty one. Then, the empty substring, the dot, and the repeated empty substring are replaced byx.