[sf-lug] bash: identifying directories
slash5toaster at gmail.com
Tue Jun 3 11:24:57 PDT 2008
On Tue, Jun 3, 2008 at 11:10 AM, Matt Price <matt.price at utoronto.ca> wrote:
> another little scripting question:
> i'd like this tiny script i'm writing to scan the current directory,
> identify the subdirectories, and then do something in each of them. so
> in pseudocode:
> [find dirs]
> for DIR in $dirs ; do
> cd $DIR
> [do some stuff]
> cd ..
> is this trivial to do? 20 minutes with the abs-guide hasn't given me
> the answer yet...
> thanks much!
# this set the delimiter to be a carriage return ONLY instead of space
plus carriage return -
#so we can handle items with a space in the name
SUBDIR=$(find . -maxdepth 1 -type d)
for DIRS in $SUBDIR
# your thing
echo "Thrashing $DIRS in $SUBDIR"
Not so bad
We are what we think. All that we are arises with our thoughts. With
our thoughts, we make the world.
More information about the sf-lug