我如何触摸或创建新文件,脚本问我一个问题,如果我想覆盖该文件已存在?脚本应该是什么样的?
答案 0 :(得分:0)
可能是这样的:
#!/bin/bash
if [ -e "$1" ]; then
echo "Want to overwrite? (Y/n)"
read ANSWER
[ "$ANSWER" = "Y" ] && touch "$1" || echo "Ok"
else
echo "Creating"
touch "$1"
fi
将其称为:./script <filename>