On Fri, 2002-06-14 at 09:29, Shaw, Marco wrote:
> I'm trying to use sed to do something like:
>
> # sh function.sh "something = yes" "something = no" file
> # cat function.sh
> #!/bin/sh
> # this is function.sh
>
> function ( ) {
> sed 's/$1/$2/g' $3 > $3.tmp
> }
>
> function
> # end of function.sh
Lot of stuff going on here.
the single quotes tell the shell to not perform parameter
interpretation. I think you will need double quotes and you will need
to tell sed that the stuff in the string is a sed script with the -e
flag.
sed -e "s/$1/$2/g" $3 >$3.tmp
Now I have not written too many functions in bash but I think you need a
name for your function, otherwise how can you call it?
function mysed () {
then you can call the function with the command mysed v1 v1 filename
Of course there is always the tr command.
Bret
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list