|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
passing variables to sed inside script
I am trying to pass a regular expression variable from a simple script to sed
to remove entries from a text file e.g. a='aaaa bbbb cccc ...|...:' then executing sed from the script sed s'/"'$a"'//g <$FILE > $FILE"_"1 my output file is always the same as the input file !! any hints / pointers are aprreciated |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
eval should accomplish what you wish.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I am not to certain what you mean and how to pass eval the command value
|
|
#4
|
||||
|
||||
|
Use awk instead of sed... Code:
awk '{gsub(a,b);print}' a="$a" b="" file1 > file2 |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
thanks for the hint, bit of modification got the script working
![]() |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
use
double qoutes instead of single quotes wil solve the problem sed "s/$a//g" inputfile>tempfile;mv tempfile inputfile will give the desired result |
| 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 |
| Problem passing a search pattern to AWK inside a script loop | quinestor | Shell Programming and Scripting | 14 | 03-14-2012 11:12 AM |
| passing arguments to unix command or script inside tclsh | Blue_shadow | Shell Programming and Scripting | 1 | 01-10-2012 04:15 PM |
| passing variables to sed function in a script .... | shweta_d | Shell Programming and Scripting | 2 | 06-05-2007 06:13 AM |
| passing variables to awk from ksh script | rein | Shell Programming and Scripting | 3 | 08-11-2005 11:29 AM |
| Passing variables from one script to another | tcoventr | UNIX for Dummies Questions & Answers | 2 | 06-18-2002 10:57 AM |
|
|