Text Processing: Find files that are not owned by a user
From WikiMLT
Get the files that are not owned by root
or user1
recursively:
sudo ls -laR /etc | \
sed -e '/root.*root/d' -e '/user1.*user1/d' \
-e '/total/d' -e '/^\/.*\n\/.*/d' -e '/^\./d' -e '/\.$/d' -e '/^$/d' | \
awk '$1 ~ /^(-|d)/ {if (a && a !~ /^(-|d)/) print a; print} {a=$0}'
References:
- Stack Overflow:
awk
print matching line and line before the matched