1

所以我试图在 bash 中创建一个文件,但我得到一个奇怪的错误,这是我的代码:

touch > "application/views/scripts/"$theFile"/"awk '{tolower($theFile".phtml")}'

错误:

./zf.sh: line 16: application/views/scripts/foo/awk: No such file or directory

我正在尝试根据用户输入创建一个文件,例如:./zf.sh: line 16: application/views/scripts/foo/foo.phtml: No such file or directory

4

3 回答 3

1

touch application/views/scripts/"${theFile}"/$(echo ${theFile} | tr '[:upper:]' '[:lower:]').phtml

于 2013-04-30T11:58:01.303 回答
1

如果你想使用 awk:

fn=`echo ${theFile} | awk '{print tolower($0)}'`
touch application/views/scripts/"${fn}".phtml
于 2013-04-30T12:06:35.703 回答
0

使用 bash(我相信是第 4 版),您不需要任何外部工具

touch "application/views/scripts/${theFile}/${theFile,,}.phtml"

http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion

于 2013-04-30T14:56:54.280 回答