The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: foreach folder
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 08-11-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Something like this:

Code:
for file in *; do
   if [ -d $file ]; then
      cd $file; mkdir test
   fi
done

-EDIT
You can skip the testing for directory as well. 'cd' won't work on anything except directories (but there might be links that point to directories and you'd end up creating "test" where you don't want to).