[英]Shell script on passing arguments
My code was like this I'm passing 4 arguments to a script 我的代码是这样的,我正在向脚本传递4个参数
ex.sh "wavpath" "featpath"
"ex.sh" code is “ ex.sh”代码是
#!/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 它位于
${dir/$wavPath/$featPath}
并且显示了两个路径
can anyone help 谁能帮忙
尝试$ {dir} / $ {wavPath} / $ {featPath}
maybe you meant $dir/$wavPath/$featPath
也许你的意思是
$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
. 并查看输出是否与预期的
mkdir
输入相同。
Also, you're not setting a value for the variable $scpFile
before you use it. 另外,在使用变量
$scpFile
之前,请不要为其设置值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.