linux – 删除文本文件中列出的文件

我有一个文件导出了一堆需要删除的文件名.我需要知道如何删除每个文件而不必在命令行一次发出一个文件.

我已经考虑过在for循环中把它括起来,这可能会起作用,但是想知道是否有一个更简单,甚至更好的解决方案来做到这一点.

谢谢.

解决方法

rm -rf `cat /path/to/filename`

“字符可以用$()替换

来自bash手册页:

Command Substitution
       Command substitution allows the output of a command to replace the command
       name.  There are two forms:

              $(command)
       or
              `command`

       Bash performs the expansion by executing command and replacing the command
       substitution  with  the  standard output of the command,with any trailing
       newlines deleted.  Embedded newlines are not  deleted,but  they  may  be
       removed  during  word splitting.  The command substitution $(cat file) can
       be replaced by the equivalent but faster $(< file).

       When the old-style backquote  form  of  substitution  is  used,backslash
       retains its literal meaning except when followed by $,`,or \.  The first
       backquote not preceded by a backslash terminates the command substitution.
       When  using  the  $(command)  form,all characters between the parentheses
       make up the command; none are treated specially.

       Command substitutions may be nested.  To nest when  using  the  backquoted
       form,escape the inner backquotes with backslashes.

       If the substitution appears within double quotes,word splitting and path‐
       name expansion are not performed on the results.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


查找全部容器的日志文件 $ sudo find /var/lib/docker/containers -name *.log 查看日志位置 $ docker inspect --format=&#39;{{.LogPath}}&#39; &lt;container_name&gt; 实时查询内容 $
Linux日志文件中列属性的详细解析
在Linux系统中没有duf命令,如何有效地管理磁盘空间?
深入探讨EncryptPad在Linux操作系统中的功能和优势
原理和应用场景:Linux中ttyload工具的工作原理和实际用途
深度解析SELinux的三种策略类型
评估Linux系统性能的ttyload工具使用效果
分享在Linux系统中检测SSH版本的方法
介绍Linux平台上的数据加密工具EncryptPad
在Linux系统中,如何查看和诊断块设备信息?
在Linux环境下如何查看块设备信息?
探索Linux操作系统下的数据加密工具EncryptPad
学会在Linux系统中查看硬盘信息
分析SELinux:原理与实践
掌握SELinux策略类别
技巧:有效解读和管理Linux日志文件
查看Linux系统中的所有用户
了解Linux系统中各种不同类型的日志文件
深入理解Linux PS命令
方法:在Linux操作系统中查看用户