LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sed problem (https://www.linuxquestions.org/questions/linux-newbie-8/sed-problem-4175519688/)

gaurav541 09-22-2014 05:36 AM

Sed problem
 
I am new to Linux and I am currently trying to learn sed. After executing this command I am little confuse

echo "123 abc" | sed 's/[0-9]/& &/'

output
1 123 abc

why it is not "1 1 abc" as & remember matched pattern.
Please explain me.

syg00 09-22-2014 06:05 AM

Change it to this and see if that explains it
Code:

echo "123 abc" | sed 's/[0-9]/---> & <---/'

pan64 09-22-2014 06:20 AM

or even:

echo "123 abc" | sed 's/[0-9]/---> & <---> & <---/'


All times are GMT -5. The time now is 11:02 PM.