|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
sed command
Hi all! Need a little help on a sed command that I've used in the past, but I'd like to change it up a bit. Here is my script Code:
SearchVal = "RED"
ReplaceVal = "BLUE"
wrkFile = /u/tmp/file1
srcFile = /usr/temp/prodfile
sed "/${SearchVal}/s/^\(.\{101\}\).\{7\}/\1${ReplaceVal}/" $wrkFile > $srcFileWhat I'm looking to do is rather than using variables, I'd like to just perform the sed command without variables. Such as.... Code:
sed "/${RED}/s/^\(.\{101\}\).\{7\}/\1${BLUE}/" /u/tmp/file1 > /usr/temp/prodfileI've tried without the "$'s" but that didn't work? am I missing something?? Thanks! |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Yes you would need to leave out the curly brackets too, that belong to the shell variables. Try: Code:
sed "/RED/s/^\(.\{101\}\).\{7\}/\1BLUE/" |
| The Following User Says Thank You to Scrutinizer For This Useful Post: | ||
macastor (01-25-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Ahhh! Thanks Scrutinizer!
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sed returns error "sed: -e expression #1, char 18: unterminated `s' command" | anand.shah | Shell Programming and Scripting | 8 | 10-15-2012 09:53 AM |
| sed insert command and variable expansion/command substitution | glev2005 | UNIX for Dummies Questions & Answers | 8 | 03-09-2010 02:18 PM |
| Convert Sed command to perl command | abacus | Shell Programming and Scripting | 2 | 11-10-2009 11:25 AM |
| Loop with sed command to replace line with sed command in it | cbo0485 | Shell Programming and Scripting | 1 | 08-27-2009 11:19 AM |
| awk/sed Command : Parse parameter file / send the lines to the ksh export command | rajan_san | Shell Programming and Scripting | 4 | 11-06-2008 12:29 PM |
|
|