Created
April 1, 2016 05:07
-
-
Save quickgrid/dbdeaa182d905e2397836afb257ba83f to your computer and use it in GitHub Desktop.
Recursively traverse the Directories and Print the file contents inside those directories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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