我有以下脚本。这是一个简单的测试用例,其中可以a
是任何字符串值,b
并且应该是路径。
#!/bin/bash
alias jo "\
echo "please enter values "\
read a \
read -e b \
echo "My values are $a and $b""
但是,每当我尝试执行./sample.sh时,都会出现以下错误:
./sample.sh: line 3: alias: jo: not found
./sample.sh: line 3: alias: echo please: not found
./sample.sh: line 3: alias: enter: not found
./sample.sh: line 3: alias: values: not found
./sample.sh: line 3: alias: read a read -e b echo My: not found
./sample.sh: line 3: alias: values: not found
./sample.sh: line 3: alias: are: not found
./sample.sh: line 3: alias: and: not found
./sample.sh: line 3: alias: : not found
当我尝试时,source sample.sh
我得到以下信息:
a: Undefined variable.
我的目的是使它成为别名,以便我可以获取此脚本并仅运行别名以执行命令行。有人可以看一下,让我知道错误是什么吗?
3
当您认为需要多行和多命令别名时,该定义一个函数或编写一个脚本了。
—
Sergiy Kolodyazhnyy
@SergiyKolodyazhnyy指出
—
Jovin Miranda