Re: shell script
Ivan wrote:
> I need to make a script incorporating the following command:
> sed -i '/$NAME/d' */test1
>
> I'm having a bit of trouble .. I'd be happy with the script to look
> like this:
>
> sed -i '/$1/d' */test1
>
> So that when I type
> $ ./script dan
>
> The command sed -i '/dan/d' */test1 would execute, but unfortunately
> it does not work this way..
>
> Not when I use
> sed -i '/$1/d' */test1
> nor when I use
> sed -i '/"$1"/d' */test1
Everything inside of the single quotes (in your case '/$1/d') will not be seen
by the shell but will passed literally to sed. Try putting eval in front of it,
to unpack the $1 first.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE d+(-) s+: a@ C+ ULAHS++$ P- L+>++ E--- W++ N++ o !K w--(+) O- M?>+ V? PS+
PE+(++) Y+ PGP- t+ 5 X R !tv b+ DI(+) D G e++ h---- r+++@ y++++
------END GEEK CODE BLOCK------
|