Created
September 10, 2019 19:43
-
-
Save guicattani/377eec1ebfec6f3cc39bd6e078cf1d6c to your computer and use it in GitHub Desktop.
Script to traverse through all folders and files inside a given folder, second argument is indentation level
This file contains 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 | |
folder="$1" | |
add_space_indentation () { | |
for i in $(eval echo "{1..$1}") | |
do | |
echo -n '-' | |
done | |
} | |
list_directories (){ | |
add_space_indentation $(($2)) | |
echo "FILES IN $1" | |
for f in $1/* | |
do | |
if [ -d "$f" ] #directory | |
then | |
list_directories $f $(($2 + 2)) | |
else #file | |
add_space_indentation $(($2)) | |
echo "$f" | |
fi | |
done | |
} | |
list_directories $folder 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment