![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Quote:
this is the not the way it works Code:
echo "a big black dog" | sed -e 's/big \(.*\) dog/small \1 cat/' a small black cat Code:
echo "a big black eared dog" |
|
||||
|
Sed -e "s/big \(.*\) dog/small \1 cat/" filename
Explanations: 1> -e - is used when using multiple replacements usinf regular expressions or not 2> you are searching for "big" and "anything after that" and then "dog" 3> you are replacing "big" with "small" and "dog" with "cat" without deterioriating the "anything after that" text when sed searches, it remembers the \(.*\) and it can be accessed using \1. hope this helps. Cheers, Devaraj Takhellambam |
![]() |
| Bookmarks |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|