简体   繁体   中英

In bash, how can I delete a file, whose name was written in a file?

For example, I have a file "~/garbage_log", the content of it is always change.

cat garbage_log
~/garbage/garbage.png
~/garbage/garbage2.jpg

now, I want a bash command to delete the file in log,how can I do it?

您可以使用以下简单的xargs命令在garbage_log文件的每一行上运行rm命令:

xargs rm < garbage_log

You can use rm to delete the files and xargs to execute the command while piping the content of the previous command.

You can do it like this: cat garbage_log | xargs sudo rm cat garbage_log | xargs sudo rm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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