find only files in directory with permissions not set to 644 on linux

Solution 1:

The ! operator returns true when a condition is false.

So while -perm 0644 matches files that have rw-r--r-- permissions set, ! -perm 0644 matches those that don't have those permissions.

The command you need is:

find /path/to/dir/ -type f ! -perm 0644 -print0 | xargs -0 chmod 644

Solution 2:

  find /path/to/dir ! -perm 0644 

And

    find /path/to/dir ! -perm 0644 -exec chmod 0644 {} \;