How do I list all files in all the user home directories?

TogaMario
TogaMario used Ask the Experts™
on
I would think something similar to this would do what I need, but it seems to take the <directory>/* literally, and not as I mean it to.

cut -d : -f 6 /etc/passwd | xargs -I{} grep umask {}/.*

For example, the output to this produces "No such file or directory" for all entries:

grep: /home/user1/.*: No such file or directory
grep: /home/user2/.*: No such file or directory

Even though user1 and user2 both have home directories with files in them.

I am running as root as well.

Thanks,
-Tyler
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2005
Commented:
What exactly You want to do?

cut -d : -f 6 /etc/passwd | xargs ls -a

Author

Commented:
Ah, I was over complicating it. That's exactly what I needed, thanks.
>How do I list all files in all the user home directories?

Modifying your command, if you want to list all files in the user home directory recursively :

cut -d : -f 6 /etc/passwd | xargs ls -lR

Best Regards


Didit

Author

Commented:
I appreciate the extra mile, but if I did that then the root user would return everything on the file system (which I could just as easily "grep -v" out, but for my intent of use I think the first example proves to be the best. I'll try to be a little more detailed in my description next time.

Thanks again!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial