Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

8.6.19 Pezzi di script ricorsivi

Il metodo seguente di agire ricorsivamente su ciascun file cercando corrispondenze *.ext assicura la gestione corretta dei nomi bizzarri dei file, tipo quelli con gli spazi, ed esegue il processo equivalente:

  • Shell loop (E' un input multiriga con PS2="> ") [39]:

         for x in *.ext; do
           if test -f "$x"; then
             command "$x"
           fi
         done
    
  • combibnazione di find e xargs:

         find . -type f -maxdepth 1 -name '*.ext' -print0 | \
          xargs -0 -n 1 command
    
  • un comando find con l'opzione -exec:

         find . -type f -maxdepth 1 -name '*.ext' \
          -exec command '{}' \;
    
  • un breve script di shell con find e l'opzione -exec:

         find . -type f -maxdepth 1 -name '*.ext' \
          -exec sh -c "command '{}' && echo 'successful'" \;
    

Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire