Cycle all folder’s file and get each name in #bash
This is pretty useful if you need to do some operations on certain files in a folder. In the example I’m cycling all files in the apache log folder, selecting only the .log files and then get the basename (no path) of the log.
DIR="/var/log/apache2";
for FILE in ${DIR}/*.log
do
FILE=`basename $FILE`;
echo "Let's do some op on $FILE";
done