#!/bin/bash
# script to recursively traverse a directory and update all last modified dates
function traverse() {
for file in "${1}"/*
do
if [ ! -d "${file}" ] ; then
echo "Found file ${file} in ${1}."
touch ${file}
printf "Updated its modification date to: " | sed 's/^/ /'
stat -c %y ${file}
else
echo "Entering directory ${file}..."
touch "${file}"/a.a
rm "${file}"/a.a
printf "Updated its modification date to: " | sed 's/^/ /'
stat -c %y ${file}
traverse "${file}"
echo "Leaving directory ${file}..."
fi
done
}
function main() {
traverse "$1"
}
main "$1"