17

Can I use find to find all files which have extended attributes set? Let's say, I want to find all files with +i, immutable attribute in /foo and its subfolders.

I could not find any, mention of extended attributes in man find.

Is there any other way to find all files with attributes

I am using Debian Wheezy

6
  • 2
    @DopeGhoti, I was about to provide the link to Gille's answer. It uses find method. The link to Gille's answer is this one. Commented Oct 15, 2014 at 20:56
  • 12
    BSD find (the same that comes with Mac OS) has both -xattr and -xattrname options to deal with extended attributes. To find files that have extended attributes set you can just use something like find . -xattr -exec xattr -v {} \;. Use -xattrname to search for specific attributes. Commented Oct 7, 2016 at 9:49
  • To delete an attribute by name for example: find ~/some-path/ -xattrname com.apple.FinderInfo -exec xattr -d com.apple.FinderInfo {} \; Commented Jan 8, 2018 at 7:45
  • @ClaudioFloreani Do you have a source for that? I can't find -xattr in any manpage from MacOS, FreeBSD or OpenBSD. Commented Aug 29, 2018 at 13:11
  • 1
    there is now a fresh utility that wraps find and supports this for any POSIX compliant OS, you can find it at github.com/Cbhihe/findxattr Commented Oct 3, 2022 at 20:19

1 Answer 1

4

find itself doesn't support extended atttribute but you can use such as:

find ~/ -type f -iname "*" -exec lsattr {} + | grep -v -- '-------------' 
2
  • 2
    This would be very slow as it runs lsattr for every single file, and there is no need to match * - use this instead: find /foo -type f -print0 | xargs -0 lsattr | grep -v -- '-------------' Commented Oct 9, 2021 at 19:28
  • 3
    Actually looking at the other answer (this one is a duplicate) lsattr supports the -R switch (recursive). Commented Oct 9, 2021 at 19:30

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.