简体   繁体   English

仅RM -rf文件

[英]RM -rf Files only

Only delete file and not folder with rm -rf 仅删除文件而不使用rm -rf删除文件夹

I have a db, which I loop through the file_path and check if file_exist 我有一个数据库,我遍历file_path并检查file_exist

If file does not exist. 如果文件不存在。 I execute 我执行

rm -rf $db_value

But sometime the db_value got empty value, which will make my script delete the folder instead. 但是有时db_value的值为空,这将使我的脚本删除该文件夹。

How do I ensure what I deleting is 100% not directory, I only want it to delete file. 如何确保删除的内容不是目录的100%,我只希望它删除文件。

以这种方式尝试:

find /path_to_files/ -type f -exec rm -f {} \;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM