所以我试图在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
答案 0 :(得分:1)
touch application/views/scripts/"${theFile}"/$(echo ${theFile} | tr '[:upper:]' '[:lower:]').phtml
答案 1 :(得分:1)
如果你想使用awk:
fn=`echo ${theFile} | awk '{print tolower($0)}'`
touch application/views/scripts/"${fn}".phtml
答案 2 :(得分:0)
使用bash(我相信版本4),您不需要任何外部工具
touch "application/views/scripts/${theFile}/${theFile,,}.phtml"
http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion