I want to quickly identify all writable files in the directory. What is the quick way to do it?
The problem with find -writable
is that it's not portable and it's not easy to emulate correctly with portable find
operators. If your version of find
doesn't have it, you can use touch
to check if the file can be written to, using -r
to make sure you (almost) don't modify the file:
find . -type f | while read f; do touch -r "$f" "$f" && echo "File $f is writable"; done
The -r
option for touch
is in POSIX, so it can be considered portable. Of course, this will be much less efficient than find -writable
.
Note that touch -r
will update each file's ctime (time of last change to its meta-data), but one rarely cares about ctime anyway.