小编bre*_*son的帖子

Tilde(〜/)如果在Shell脚本中使用then语句则不起作用

我有以下脚本

file=${file:-letsdump.sh}    
checkfile="~/mysql_backup/$file"
if [ -e "$checkfile" ]; then
mv ~/mysql_backup/$file ~/mysql_backup/$file-bak-$(date +%d%m%Y_%H%M).bak
else
echo 'file doesnt exist'   
fi
Run Code Online (Sandbox Code Playgroud)

我知道我的文件在那里,我在想它可能与〜/?有关

它永远不会找到该文件

shell if-statement file

2
推荐指数
1
解决办法
759
查看次数

标签 统计

file ×1

if-statement ×1

shell ×1