From: Glynn Clements Subject: Re: shell/Perl question Date: Wed, 3 Nov 2004 04:44:25 +0000 Message-ID: <16776.25129.571630.868175@cerise.gclements.plus.com> References: Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-admin-owner@vger.kernel.org List-Id: Content-Type: text/plain; charset="us-ascii" To: vick Julius Cc: linux-admin@vger.kernel.org vick Julius wrote: > > for dir in ABC DEF GHI ; do > > for file in `(cd "$dir" && echo *.jpg)` ; do > > mv "$dir/$file" "Photos/${file%%.jpg}$dir.jpg" > > done > > done > > > What is the use of echo *.jpg in (cd "$dir" && echo *.jpg)? That fragment outputs the list of files in the current directory (which will be $dir due to the preceding "cd"). > Is it mandatory? There are other ways to do it; e.g. using "ls *.jpg" would also have worked, but "echo" is built in to the shell. > Where can I find more details on ${file%%.jpg} stuff? is it in the bash > manual?... It's in the bash manual, in the section entitled "Parameter Expansion". -- Glynn Clements