Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

shell - Exclude specific path from find's output

I searched inside my filesystem for files with a specific extension using find

find / -type f -name "*.click" 2>/dev/null

In my result I get a lot of files in a specific path which are not interesting for me like

/home/x/Dokumente/click/etc/samplepackage/test.click
/home/x/Dokumente/click/apps/csclient/test.click
/home/x/Dokumente/click/conf/test-device.click
/home/x/Dokumente/click/conf/ip6ndadvertiser.click
/home/x/Dokumente/click/conf/script-parabolawave.click
/home/x/Dokumente/click/conf/fake-iprouter.click
/home/x/Dokumente/click/conf/fromhost-tunnel.click
/home/x/Dokumente/click/conf/simple-dsdv-userlevel.click
/home/x/Dokumente/click/conf/sampler.click
/home/x/Dokumente/click/conf/script-trianglewave.click
/home/x/Dokumente/click/conf/script-squarewave.click
/home/x/Dokumente/click/conf/fastudpsrc.click
/home/x/Dokumente/click/conf/schedorder1.click
/home/x/Dokumente/click/conf/test-ping-userlevel.click
/home/x/Dokumente/click/conf/test-tcp.click
/home/x/Dokumente/click/conf/delay.click
/home/x/Dokumente/click/conf/icmp6error.click
/home/x/Dokumente/click/conf/webgen.click
/home/x/Dokumente/click/conf/test2.click
/home/x/Dokumente/click/conf/grid.click
/home/x/Dokumente/click/conf/thomer-nat.click
/home/x/Dokumente/click/conf/gnat02.click
/home/x/Dokumente/click/conf/test-clicky.click
/home/x/Dokumente/click/conf/ip64-nat3.click
/home/x/Dokumente/click/conf/mazu-nat.click
/home/x/Dokumente/click/conf/ip6print.click
/home/x/Dokumente/click/conf/gnat01.click
/home/x/Dokumente/click/conf/ip601.click

In this article I found an answer and tried like this below

find / -type f -name "*.click" -not -path "./home/ipg7/Dokumente/click/conf"  2>/dev/null

But it doesn't work I still get the output as before.

So how can I exclude a specific path and also write all the permission denied to /dev/null?

question from:https://stackoverflow.com/questions/65917346/exclude-specific-path-from-finds-output

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You've added -not -path "./home/ipg7/Dokumente/click/conf" which does not match anything in your output due to

  1. starting with a dot,
  2. missing the pattern that matches the file part

Try -not -path "/home/ipg7/Dokumente/click/conf/*" instead


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...