Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #208321
| From | David Wright <deblis@lionunicorn.co.uk> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: [SOLVED] Re: Shell Script Help |
| Date | 2019-05-06 22:20 +0200 |
| Message-ID | <xUSfD-2qH-1@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <xUMDf-7jv-3@gated-at.bofh.it> <xUMMV-7mO-1@gated-at.bofh.it> <xUOYq-am-3@gated-at.bofh.it> <xUPhM-wy-3@gated-at.bofh.it> <xUQ4a-Ud-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon 06 May 2019 at 10:56:47 (-0700), Patrick Bartek wrote:
> On Mon, 6 May 2019 13:08:05 -0400 Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> > 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.
>
> Silly me. I failed to substitute the correct dir name letters in the
> script for example "ab" prefix I origninaly posted. Didn"t even notice
> until I started troubleshooting 3 hours later. That's what I get for
> reading the list a 6:00am. With semi-colons properly placed for a one
> liner, it works.
You don't really need to place semicolons anywhere for a one-liner;
the system does it for you. I've cut and pasted Greg's example into
the command line, and then pressed Uparrow (for history recall):
$ for dir in ab*/; do
> name=${dir%/}
> enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg
> done
bash: enfuse: command not found
$ for dir in ab*/; do name=${dir%/}; enfuse --output "$name.jpg" --compression=97 "$dir"/*.jpg; done
and there's your one-liner.
Cheers,
David.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Shell Script Help Patrick Bartek <patrick.bartek@gmail.com> - 2019-05-04 17:30 +0200
Re: Shell Script Help john doe <johndoe65534@mail.com> - 2019-05-04 20:30 +0200
Re: Shell Script Help Patrick Bartek <nemommxiv@gmail.com> - 2019-05-06 16:10 +0200
Re: Shell Script Help Richard Owlett <rowlett@cloud85.net> - 2019-05-04 22:40 +0200
Re: Shell Script Help Patrick Bartek <patrick.bartek@gmail.com> - 2019-05-06 16:20 +0200
Re: Shell Script Help Greg Wooledge <wooledg@eeg.ccf.org> - 2019-05-06 16:30 +0200
Re: Shell Script Help john doe <johndoe65534@mail.com> - 2019-05-06 18:20 +0200
Re: Shell Script Help Patrick Bartek <nemommxiv@gmail.com> - 2019-05-06 19:00 +0200
Re: Shell Script Help Patrick Bartek <nemommxiv@gmail.com> - 2019-05-06 18:50 +0200
Re: Shell Script Help Greg Wooledge <wooledg@eeg.ccf.org> - 2019-05-06 19:10 +0200
[SOLVED] Re: Shell Script Help Patrick Bartek <nemommxiv@gmail.com> - 2019-05-06 20:00 +0200
Re: [SOLVED] Re: Shell Script Help David Wright <deblis@lionunicorn.co.uk> - 2019-05-06 22:20 +0200
Re: [SOLVED] Re: Shell Script Help Patrick Bartek <nemommxiv@gmail.com> - 2019-05-07 03:30 +0200
Re: Shell Script Help Dan Purgert <dan@djph.net> - 2019-05-06 20:10 +0200
Re: Shell Script Help Will Mengarini <seldon@eskimo.com> - 2019-05-05 03:10 +0200
Re: Shell Script Help Patrick Bartek <patrick.bartek@gmail.com> - 2019-05-06 16:20 +0200
csiph-web