猛砸无法创建文件

问题描述:

所以我试图建立在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

如果你想使用周:

fn=`echo ${theFile} | awk '{print tolower($0)}'` 
touch application/views/scripts/"${fn}".phtml 

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

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

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

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