![]() |
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 |
|
|
|
||||
|
I have this line "%is xxx = 123" in a program. I want to use sed command to replace it with something else but part of this line is not the same all the time. For example, it could be "%is xxx = 456" (and these three number change all the time)
I have: sed 's/%is xxx = 123/my replacement/g' programfile > newfile What modify I need to do to have it works wether it /%is xxx = 123, /%is xxx = 456 or so? I know ^ this begin of the line and $ is end of the line sed 's/%is xxx = ***$/my replacement/g' programfile > newfile Please advise! Thanks! |
|
||||
|
What happen if the data is
$ cat tmp %is xxx = 123 be 123 How to code it so it will ignore 123 be 123. I know that "%is xxx = " is the exact pattern everytime the rest of the line is unknown using the code below I will get $ sed 's/^\(%is xxx = \)[0-9]*\( *.*\)$/\11234\2/g' tmp %is xxx = 1234 be 123 I am only interested to get: %is xxx = 1234 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|