User Tools

Site Tools


n-times_commands

Repeat n times the same command with different arguments

One-liners

  • If you need to process several files:

for i in `cat file_with_the_names_each_one_in_a_different_line`; do echo $i ; done

This actually prints the names of the files to process

  • If you do not have the names, but they are in the same directory:

for i in `ls -1 *.pdb`; do echo $i ; done

  • If you need to repeat n times the command

for i in `seq 1 5`; do echo “This is the iteration $i” ; done

Script version

One-liners also work for scripts but, if you need to make the structure clear:

for i in `ls -1 *.pdb`; do
echo $i
done


n-times_commands.txt · Last modified: 2016/03/07 14:28 by root