my command is
sh abc.sh 'hello'
Inside my shell script abc.sh
var1=$1
sed -i "s/'/ /g" $var1
but sed
is not working
my command is
sh abc.sh 'hello'
Inside my shell script abc.sh
var1=$1
sed -i "s/'/ /g" $var1
but sed
is not working
sed wait filename in argument (see man sed
)
sed [OPTION] .... {script-only-if-no-other-script} [input-file]
Into your script, you need to change to:
echo "$var1" | sed "s/'/ /g"
You are performing sed on a variable and not a file and so redirect the variable back into sed to get the desired result:
sed "s/'//g" <<< "$var1"
This avoids the inefficiencies associated with echo "$var1" | sed .....
An alternative to sed in this use case is tr and so:
tr -d "'" <<< "$var1"
Use -d "'" to pass the character you want to delete from the text.