[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell Script Help



On Mon, May 06, 2019 at 09:41:58AM -0700, Patrick Bartek wrote:
> On Mon, 6 May 2019 10:24:24 -0400
> Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> > for dir in ab*/; do
> >     name=${dir%/}
> >     enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> > done
> 
> Typed in as a single line with a semi-colon at end of enfuse command
> and before done to keep it from locking up, generates error "enfuse:
> failed to open "ab*//*.jpg: No such file or directory. But it's a
> beginning. Time to pull out my 400 page Unix shell programming book.

Most likely it means there weren't any matching directories wherever
you ran it.  The ab*/ glob will be used literally if it doesn't match
any directories.

If you want to check for that, you can add a test.

for dir in ab*/; do
    test -d "$dir" || continue
    name=${dir%/}
    enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
done

You said you had twenty-something directories named ab01, ab02, etc.
So it should have matched unless you ran it from the wrong place,
or unless you lied about your directory names.

But nobody would EVER lie about their directory names in a shell
programming question.  Oh, no, never.


Reply to: