加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – -maxdepth选项后不能选择AND find:path必须先于表达式

发布时间:2020-12-13 18:35:19 所属栏目:Linux 来源:网络整理
导读:希望有人可以帮助这个: 尝试使用此命令删除/ tmp上的会话文件: find /tmp -name 'sess_*' -user Username -maxdepth 1 $CMD {} ; 但是我收到以下错误: find: warning: you have specified the -maxdepth option after a non-option argument -name,but o
希望有人可以帮助这个:

尝试使用此命令删除/ tmp上的会话文件:

find /tmp -name 'sess_*' -user Username -maxdepth 1 $CMD {} ;

但是我收到以下错误:

find: warning: you have specified the -maxdepth option after a
non-option argument -name,but options are not positional (-maxdepth
affects tests specified before it as well as those specified after
it). Please specify options before other arguments.

06001

我通过网络寻找解决方案,但找不到任何解决方案.我已经删除其他tmp文件与其他命令,并怀疑是否影响一些卷或套接字.

先谢谢你

解决方法

find有三种类型的选项:用于匹配文件的选项(例如-name,-user),指定在匹配文件(-print,-exec)上执行的操作的选项以及控制整个行为的选项命令(例如-maxdepth,-xdev).第三种必须放在另外两种之前.所以应该是:
find /tmp -maxdepth 1 -name 'sess_*' -user Username -exec $CMD {} ;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读