在以下脚本中,如何添加chmod 777
以便可以使用777权限创建文件?如何用777权限创建文件?
file="New_file.txt";cd \abc\efg\; if [ ! -f $file ] ; then touch $file; fi;
在以下脚本中,如何添加chmod 777
以便可以使用777权限创建文件?如何用777权限创建文件?
file="New_file.txt";cd \abc\efg\; if [ ! -f $file ] ; then touch $file; fi;
它看起来相当明显:
file="New_file.txt"
cd "your_dir"
if [ ! -f "$file" ]; then
touch "$file"
chmod 777 "$file"
fi
注意你应该引用变量,也cd
,这样你就不必逃避。它还可以防止出现意外的行为,如果文件名包含空格,换行...
一个内胆:
file="new"; cd "your_dir"; if [ ! -f "$file" ]; then touch "$file"; chmod 777 "$file"; fi
试试这个:
file="New_file.txt"; cd /abc/efg/; if [ ! -f $file ] ; then touch $file; chmod 777 $file; fi
你真的使用'CD \ ABC \ EFG \'?另外,如果文件已经存在,chmod 777是否必须应用? – fedorqui 2014-10-22 11:29:42
我必须创建该文件,如果不存在于具有所有权限的文件夹中!但是那只发生一次!无论如何,我已经解决了我的问题!谢谢 – Bobby 2014-10-22 11:43:31