shell脚本判断文件为空
时间: 2023-10-24 20:08:54 浏览: 126
在shell脚本中,可以使用test指令来判断文件是否为空。一种常见的写法是使用-s选项。例如,在给定的脚本中,使用了`if [ -s file.txt ]; then`的语法来判断文件file.txt是否为空。如果文件不为空,则执行相应的操作;如果文件为空,则执行另一种操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [【转载】如何在shell中判断一个文件是否为空](https://blog.csdn.net/weixin_30267691/article/details/95955057)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [shell 检查空文件](https://blog.csdn.net/m0_64435849/article/details/121722793)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文