我想编写一个shell脚本来检查某个文件archived_sensor_data.json是否存在,如果存在,则删除它.在
http://www.cyberciti.biz/tips/find-out-if-file-exists-with-conditional-expressions.html之后,我尝试了以下方法:
[-e archived_sensor_data.json] && rm archived_sensor_data.json
但是,这会引发错误
[-e: command not found
括号和-e之间缺少空白.
#!/bin/bash if [ -e x.txt ] then echo "ok" else echo "nok" fi