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.