In short, I decided to write up a function with a short name that I could use as an alias:
# list only hidden files in the given directory(s)
function lh() {
# if directories were given
if [ $# -gt 0 ]; then
# store current dir so we can come back
startingPath=`pwd`
# loop through input dirs
for i in $*; do
# only list contents for directories
if [ -d $i ]; then
cd $i # cd to the directory
echo $i: # print a header
ls -Ad .** # list hidden files
else
echo Ignoring directory: $i
fi
echo # blank line for readability
done
# cd back to your original directory
cd $startingPath
else
# just list hidden files for current directory
ls -Ad .**
fi
}
No comments:
Post a Comment