简体   繁体   中英

Shell script on passing arguments

My code was like this I'm passing 4 arguments to a script

ex.sh "wavpath" "featpath"

"ex.sh" code is

#!/bin/bash

wavPath=$1
featPath=$2
rm -f $scpFile

echo $wavPath
echo $featPath


for dir in `ls -R $wavPath|grep ":"|cut -d':' -f1`
do
    mkdir -p ${dir/$wavPath/$featPath}
done

The error message:

bad substitution

and it is at ${dir/$wavPath/$featPath} and its showing both the paths

can anyone help

尝试$ {dir} / $ {wavPath} / $ {featPath}

maybe you meant $dir/$wavPath/$featPath

try changing

mkdir -p ${dir/$wavPath/$featPath}

to

echo $dir/$wavPath/$featPath

and see if the output is what you expected for the input of mkdir .

Also, you're not setting a value for the variable $scpFile before you use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM