PTT
Submit
Submit
选择语言
正體中文
简体中文
PTT
Linux
[问题] 请问 find 排除某些档案的方式
楼主:
s8454158
(′‧ω‧‵)
2017-06-30 02:59:11
小弟想要每日删除在/opt/123/log 内的所有档案,但是要排除连结指向的档案...
以下是目录底下的资料:
/opt/123/log/aaa.ERROR -> ERROR20170622-091436.1204
/opt/123/log/aaa.WARNING -> ERROR20170622-211432.4204
/opt/123/log/aaa.INFO -> INFO20170622-221431.1927
/opt/123/log/bbb.ERROR -> ERROR20170622-091432.1477
/opt/123/log/bbb.WARNING -> ERROR20170622-111432.8437
/opt/123/log/bbb.INFO -> INFO20170622-091438.1277
其余还有一大堆类似的档案,上面六个档案档名会变动也不能搬移 = =
有方法可以写 shell script 用 find 排除某些特定档案一次杀光其他档案吗??
感恩~
作者:
dododavid006
(朔雪)
2017-06-30 10:41:00
find /opt/123/log/* -not -type l -delete这样会排除掉 symbol link 的档案不过资料夹下如果只有 regular file 要删的话建议find /opt/123/log/* -type f -delete
楼主: s8454158 (′‧ω‧‵)
2017-06-30 12:25:00
谢谢 那symbol link 指向的档案也要一起排除呢?
作者: yvb
2017-06-30 21:49:00
find /opt/123/log/ -type l | \(sed 's/^/! -samefile /;s/$/ -a/';echo ' -type f') | \xargs find -L | xargs rm
继续阅读
[问题] mac terminal 2>&1 导向的问题
TJrose
[问题] 使用Gnome-terminal,如何储存记录档?
marx625001
[问题] CentOS(1611)安装时GPT设定
jog199
[问题] 关于时间设定
shinchun
[问题] 关于MySQL跟mariaDB双向同步问题
peterh05
[问题] 登入输入密码 跳回登入画面
johnny9667
[问题] SourceExplorer乱跳
blueguan
[问题] snmp在raspbian上安装遇到的问题
losttype
[问题] Ubuntu系统和软件更新卡住?
dharma
Re: [问题] Linux desktop的某个评价?
bced
Links
booklink
Contact Us: admin [ a t ] ucptt.com