scriptdir=`dirname $0` 不起作用

kol*_*nel 6 unix shell-script

我正在尝试使用以下方法获取我的脚本所在的目录:

scriptdir=`dirname $0`
Run Code Online (Sandbox Code Playgroud)

但这给了我以下错误:

dirname: invalid option -- 'b'
Try `dirname --help' for more information.
Run Code Online (Sandbox Code Playgroud)

我尝试了他们推荐的(即dirname --help),但它说找不到命令。我该如何解决这个问题?

我正在尝试使用 scriptdir 变量,以便我可以编译以下 java 程序:

java -mx800m -cp "$scriptdir/*" edu.stanford.nlp.parser.lexparser.LexicalizedParser -retainTmpSubcategories -outputFormat "typedDependencies"  -outputFormatOptions "basicDependecies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ./sentences/100000.txt > ./parsedsentences/100000.txt
Run Code Online (Sandbox Code Playgroud)

小智 9

dirname -- "$0"

- (破折号破折号)停止dirname从处理所述参数的任何选项。$0如果名称中有空格,请始终引用。