Skip to content

bash script to loop over unix linux command

taken roughly from https://www.cyberciti.biz/faq/bash-for-loop/

either chmod this file to make it executable and run it by typing /.filename; or else

type bash ./filename

#!/bin/bash

for i in {1..9}

do

ls -als puppi_blah$i.fits

done


on the other hand, infinite loop (straight from above link)

for (( ; ; ))
do
   echo "infinite loops [ hit CTRL+C to stop]"
done

Loop with break on error (straight from above link)

for I in 1 2 3 4 5
do
  statements1      #Executed for all values of ''I'', up to a disaster-condition if any.
  statements2
  if (disaster-condition)
  then
	break       	   #Abandon the loop.
  fi
  statements3          #While good and, no disaster-condition.
done
Published inUnix Hint

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *