replacing / to -

Hi,
i am running a shell script where i have assigned a variable to the value passed.

so my variable is
var1="investment/portfolio/run.job"

now i want to assign another variable var2 as

"investment-portfolio-run.out"

how can i do it using awk or something else....

thanks

# echo "investment/portfolio/run.job" | sed 's/\//\-/g'
investment-portfolio-run.job
var1="investment/portfolio/run.job"

var2=`echo $var1 | sed 's/\//\-/g'`

echo $var2

these two will also do :slight_smile:

echo "investment/portfolio/run.job" |tr "/" "-"
echo "investment/portfolio/run.job" |awk '/\//{gsub("/","-")}{print}'