Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.unix.shell > #21462
| Path | csiph.com!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx17.ams4.POSTED!not-for-mail |
|---|---|
| From | Spiros Bousbouras <spibou@gmail.com> |
| Newsgroups | comp.unix.shell |
| Subject | Re: finding directories based on files within? |
| Message-ID | <qMPRgfB8sGSKBlu44@bongo-ra.co> (permalink) |
| References | <eli$2105101745@qaz.wtf> |
| In-Reply-To | <eli$2105101745@qaz.wtf> |
| X-Organisation | Weyland-Yutani |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 8bit |
| Lines | 28 |
| X-Complaints-To | http://netreport.virginmedia.com |
| NNTP-Posting-Date | Thu, 13 May 2021 02:38:32 UTC |
| Organization | virginmedia.com |
| Date | Thu, 13 May 2021 02:38:32 GMT |
| X-Received-Bytes | 1795 |
| Xref | csiph.com comp.unix.shell:21462 |
Show key headers only | View raw
On Mon, 10 May 2021 22:13:50 +0000 (UTC)
Eli the Bearded <*@eli.users.panix.com> wrote:
> I currently have a simple shell script along the lines of:
>
> find "$1" -type d \
> -exec test -f {}/SENTINEL-1 \; \
> -exec test -f {}/SENTINEL-2 \; \
> -print
>
> The idea is to list directories that satisfy the condition of having two
> exactly named files within them. This code works, but it's not exactly
> fast (two execs for each matched directory), and it doesn't scale well:
> three files or has one but NOT the other, has either one of them, has
> sub-directories of particular names etc, all require rewriting the whole
> command.
Perhaps
find "$1" -type d -printf '[ -f %p/SENTINEL-1 -a -f %p/SENTINEL-2 ] && echo %p\n' | sh
You would need to do minimal rewriting for the other uses you mention. But
it won't work if the file names may contain characters which are special
to the shell.
> The way I use this tool, it needs to examine both immediate
> subdirectories of "$1" and one level further.
I would need to see an example to be clear what this means.
Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
finding directories based on files within? Eli the Bearded <*@eli.users.panix.com> - 2021-05-10 22:13 +0000
Re: finding directories based on files within? Spiros Bousbouras <spibou@gmail.com> - 2021-05-13 02:38 +0000
Re: finding directories based on files within? Martijn Dekker <martijn@inlv.demon.nl> - 2021-05-13 04:50 +0200
Re: finding directories based on files within? Ed Morton <mortonspam@gmail.com> - 2021-05-13 07:20 -0500
Re: finding directories based on files within? Ed Morton <mortonspam@gmail.com> - 2021-05-13 09:04 -0500
Re: finding directories based on files within? Axel Reichert <mail@axel-reichert.de> - 2021-05-13 14:56 +0200
Re: finding directories based on files within? Ed Morton <mortonspam@gmail.com> - 2021-05-13 08:44 -0500
Re: finding directories based on files within? Axel Reichert <mail@axel-reichert.de> - 2021-05-13 21:09 +0200
Re: finding directories based on files within? merlyn@stonehenge.com (Randal L. Schwartz) - 2021-05-13 07:31 -0700
Re: finding directories based on files within? Eli the Bearded <*@eli.users.panix.com> - 2021-05-13 17:11 +0000
Re: finding directories based on files within? Christian Weisgerber <naddy@mips.inka.de> - 2021-05-13 22:04 +0000
Re: finding directories based on files within? merlyn@stonehenge.com (Randal L. Schwartz) - 2021-05-15 06:45 -0700
find2perl (Was: finding directories based on files within?) gazelle@shell.xmission.com (Kenny McCormack) - 2021-05-15 17:32 +0000
Re: find2perl Dan Espen <dan1espen@gmail.com> - 2021-05-15 13:46 -0400
Re: find2perl (Was: finding directories based on files within?) Christian Weisgerber <naddy@mips.inka.de> - 2021-05-15 20:17 +0000
Re: find2perl (Was: finding directories based on files within?) gazelle@shell.xmission.com (Kenny McCormack) - 2021-05-16 13:06 +0000
Re: find2perl merlyn@stonehenge.com (Randal L. Schwartz) - 2021-05-15 15:34 -0700
csiph-web