BASH Shell script - foreach file in a directory

Published: Friday, 14 April 2006

Example that lists all files in the /tmp directory.

#!/bin/sh

for filename in /tmp/*
do
  echo $filename
done;