在以下脚本中,如何添加chmod 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句