LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-22-2014, 06:36 AM   #1
gaurav541
LQ Newbie
 
Registered: Sep 2014
Posts: 1

Rep: Reputation: Disabled
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.

Last edited by gaurav541; 09-22-2014 at 06:46 AM.
 
Old 09-22-2014, 07:05 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,840

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Change it to this and see if that explains it
Code:
echo "123 abc" | sed 's/[0-9]/---> & <---/'
 
1 members found this post helpful.
Old 09-22-2014, 07:20 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,121

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
or even:

echo "123 abc" | sed 's/[0-9]/---> & <---> & <---/'
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] a problem about sed android2009 Programming 2 08-30-2010 01:06 AM
sed problem kazemipouya Linux - Newbie 4 08-18-2009 04:37 AM
Sed problem Miro1 Programming 3 04-09-2005 10:02 AM
a sed problem thanhVic Programming 5 03-02-2005 02:05 AM
sed problem fossilet Linux - Software 4 12-26-2004 06:44 AM


All times are GMT -5. The time now is 06:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration