If you have cd'd into the $1 directory, you list the files with *
($i/* lists the file in the $1 directory when you have not done a cd.)
Code:
#!/bin/bash
rows=""
name=""
if [ -d "$1" ] ; then
cd "$1"
else
echo "Invalid directory name - exiting. Usage: ${0##*/} <directory>"
fi
for f in *
do
...
Or simply trust that a failing cd will give an appropriate error message.
Code:
#!/bin/bash
rows=""
name=""
cd $1 || exit
for f in *
do
...