skip to main | skip to sidebar

Random

Saturday, June 7, 2008

Shell script for loops

To do a list of commands over and over for each subdirectory, type:

sh
for i in `ls -d ./*/`
do
cd $i
(list of commands like mv ../a . or perl blog.pl *blog*.html etc.)
cd ..
done
exit
Posted by Kathy at 7:49 AM
Labels: command, script, shell, unix

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2012 (2)
    • ►  June (1)
    • ►  April (1)
  • ►  2010 (5)
    • ►  May (1)
    • ►  March (1)
    • ►  February (2)
    • ►  January (1)
  • ►  2009 (4)
    • ►  August (1)
    • ►  April (1)
    • ►  March (2)
  • ▼  2008 (20)
    • ►  November (2)
    • ►  September (4)
    • ▼  June (10)
      • tcpdump for capturing packets and headers
      • Shell script for loops
      • List only directories in Unix
      • Parenthesized search and replace in vi
      • vi search and replace with regular expressions
      • Reformatting drives in unix
      • Execute shell commands from java
      • What line number you're on in vi
      • vi commands - insert at beginning or end of every ...
      • Listing directory sizes in Unix
    • ►  May (4)

About Me

Kathy
View my complete profile