Last active
April 13, 2017 20:09
-
-
Save tanzyy/4db3af0e00e7903456ef29768a2529eb to your computer and use it in GitHub Desktop.
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 | |
# This method finds last name separated by /, helps in getting directory or file name without path. | |
print_name() { | |
echo $1 | awk -F "/" '{ print $NF }' | |
} | |
dir_name=/Users/tanzyy/_temp/logshomedir/* | |
for d in $dir_name; do | |
if [ -d "$d" ]; then | |
# Here you can find example of how to call method in echo method | |
echo "Its dir - " $(print_name $d) | |
for f in $d/*; do | |
echo "The file is " $(print_name $f) | |
done | |
else | |
echo "Its file - " $(print_name $d) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment