In a follow-up to my previous post, I got tired of typing things. And so I came up with this script:
[findWriteableFiles.sh]
#!/bin/bash
# Put arguments into an array
#
args=$@
# If no arguments, set firt value to current dir.
#
if [ -z "${args[0]}" ]; then
args[0]=.
fi
# Loop over supplied paths and find writeable files
#
for arg in $args; do
find $arg -type f -perm /u=w | grep -v "\.class" | grep -v tmp-bin | \
grep -v aTest | grep -v fixToStuff | grep -v build/ | grep -v gensrc/ | \
grep -v Reference | grep -v "~" | grep -v "classes" | grep -v "buildtree"
done
exit
My only detail to sort out was exactly how to refer to $@. Apparently if you quote it (being exactly “$@”) that takes all the arguments as a single string. Unquoted, it takes them separately and gets what I’m looking for.
As you can see, I also have a lot of cruft I don’t want to see in my results, so I use good ol’ “grep -v” to weed it out. Yes, I know there is a way to use egrep to make that all one command, but for some reason it doesn’t always want to play nicely for me. So in a classic “eff it, let the script deal with it” I just chain some pipes. I think if I had thousands of files to sort through, this would suck. But I don’t, so it doesn’t.