On Fri, Mar 13, 2009 at 09:04:48AM +0000, Brett Parker wrote:
On 12 Mar 21:04, Chris G wrote:
I often have this problem! :-)
How can one refer to all one's own files and directories easily?
E.g. I am sitting at /home/chris and, for whatever reason, I want to apply a command to all the files, including hidden files.
A command like this for example (where I have moved some files in which belong to someone else), I become root and do:-
chown -R chris *
Well, that's OK but it doesn't include hidden files, so:-
chown -R chris .*
That's no good either because it tries to run the command on .. as well as . and the hidden files.
There are things like:-
chown -R chris .[a-zA-Z][a-zA-Z]*
but it feels like there should be an easier way. I know there's better syntax than [a-zA-Z][a-zA-Z]* (using + I think), but it's still hardly elegant.
In the case of chown, you just give it the directory if you're using -R, so that'd be chown -R /home/chris and it'd be done.
Good point! :-)
For generic cases, though - find and xargs (or find with the exec + option) are going to be the right way.
Yes, xargs would seem to be the answer, thank you (and the other reply). I must try and remember about xargs, it's not something that I know/use a lot at the moment.