I'm using Mac OSX Lion and I would like to have a script that tells me if a directory is hidden or visible. the directory is .whatyoulookingatfool.
This is what I have now...
#!/bin/bash
#Check for dir
if test -d /Users/NSutton/Documents/.whatyoulookingatfool; then
echo "go go go"
else
echo "well shit"
fi
I don't have any osx machine right here, but I assume that mac has a basename command and new enough bash.
#!/bin/bash
dir=$1
bn=$(basename $dir)
if [[ -d $dir && $bn == .* ]]
then
echo yep
else
echo nay
fi
Note that this does not work with .
and ..
directories.