Re: bash Shell Scripting Question

2012-09-20 Thread Polytropon
On Thu, 20 Sep 2012 11:16:40 +0200, Jan Henrik Sylvester wrote: > On 09/20/2012 04:29, Polytropon wrote: > > Correct. You could use different approaches which may or may > > not fail due to the directory names you will encounter (like > > directories with spaces or special characters). > > > >

Re: bash Shell Scripting Question

2012-09-20 Thread Martin McCormick
Many thanks! The for loop was what was needed. Polytropon writes: > Just a sidenote: If you're not using bash-specific functionality > and intend to make your script portable, use #!/bin/sh instead. I always start out that way for that very reason. I needed some random number functions and arithm

Re: Re: bash Shell Scripting Question

2012-09-20 Thread Jan Henrik Sylvester
On 09/20/2012 04:29, Polytropon wrote: Correct. You could use different approaches which may or may not fail due to the directory names you will encounter (like directories with spaces or special characters). #!/bin/sh for DIR in `ls -LF | grep \/`; do cd ${DIR}

Re: bash Shell Scripting Question

2012-09-19 Thread Polytropon
On Wed, 19 Sep 2012 21:03:11 -0500, Martin McCormick wrote: > I just discovered a knowledge deficiency on my part that > I can't seem to resolve. > > If one writes a loop of the following form: > > #!/usr/local/bin/bash Just a sidenote: If you're not using bash-specific functionalit

Re: bash Shell Scripting Question

2012-09-19 Thread Mihai Donțu
On Wed, 19 Sep 2012 21:03:11 -0500 Martin McCormick wrote: > #!/usr/local/bin/bash > ls -LF |grep \/ >/tmp/files > while read dirname; do > cd $dirname > #Do whatever commands to be repeated in each directory. > done < /tmp/files > How about: ls -LF | grep \/ | while read dirname; do cd $