Here’s a simple one-liner I came up with to remove all HFS+ extended attributes on all files and directories below the current one in Mac OS X. Useful before creating a tar file that will be shared with non-Mac users (tar in OSX will create additional “resource” files to store extended attributes, which when untared on a Mac will be correctly reinstated, but in other systems will leave spurious hidden files all over the place).
for i in $(ls -Rl@ | grep '^ ' | awk '{print $1}' | sort -u); \
do echo Removing $i ... >&2; \
find . | xargs xattr -d $i 2>/dev/null ; done
The space after the caret in the grep command is produced by typing Ctrl-V and then Tab, to insert a Tab character.
