Here is a solution:
#!/bin/bash
target="/home/personal/scripts/07_22_13/ford/$1"
let count=0
for f in "$target"/*
do
echo $(basename $f)
let count=count+1
done
echo ""
echo "Count: $count"
Solution 2
If you don't want to deal with parsing the path to get just the file names, another solution is to cd
into the directory in question, do your business, and cd
back to where you were:
#!/bin/bash
target="/home/personal/scripts/07_22_13/ford/$1"
pushd "$target" > /dev/null
let count=0
for f in *
do
echo $f
let count=count+1
done
popd
echo ""
echo "Count: $count"
The pushd
and popd
commands will switch to a directory, then return.