Automation: For loops in bash (for loops on the command line)

September 23, 2013

If you have to run a script that processes data for a particular file for a particular day, i.e. your file is on hadoop with the date in the path, like this:

/path/to/my/data/2013/09/23/*

And you have multiple days to process, don’t run them manually. Use a for loop instead:

for day in {19..22}
do
  ./my_script.sh 2013/09/\$day
done
#command line