Skip to content

Instantly share code, notes, and snippets.

@quickgrid
Created April 1, 2016 05:07
Show Gist options
  • Save quickgrid/dbdeaa182d905e2397836afb257ba83f to your computer and use it in GitHub Desktop.
Save quickgrid/dbdeaa182d905e2397836afb257ba83f to your computer and use it in GitHub Desktop.
Recursively traverse the Directories and Print the file contents inside those directories.
#!/bin/bash
#Recursively traverse the Directories and
#Print the file contents inside those directories.
readFile(){
while read line
do
echo "$line"
done < "$1"
}
traverseDirectory(){
for fileName in `ls $1/`
do
if [ -f $1/$fileName ]; then
echo ""
echo "Contents of: $1/$fileName :"
echo "==========================="
readFile $1/$fileName
echo ""
fi
if [ -d $1/$fileName ]; then
echo "$1/$fileName"
traverseDirectory "$1/$fileName"
#rm -rf $1/$fileName
fi
done
}
var='deletefolder'
traverseDirectory $var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment