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.
ls -A | xargs chown -R chris ?
On Thu, 2009-03-12 at 21:04 +0000, 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.
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.
For generic cases, though - find and xargs (or find with the exec + option) are going to be the right way.
HTH HAND,
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.
Chris, with your vast "experiences" you so often speak of, surely you would have found an alternate to the god awful use of chown and a wildcard expansion by now?
On Fri, Mar 13, 2009 at 09:40:22AM +0000, steveydoteu wrote:
Chris, with your vast "experiences" you so often speak of, surely you would have found an alternate to the god awful use of chown and a wildcard expansion by now?
Like what? It's crude quick and simple but did basically what I needed in that particular case. Why try to be any cleverer?
Re my 'experience', a great deal of it is on old[ish] Solaris systems, and also various other (often old) varieties of Unix. I thus tend to go for "lowest common denominator" types of command because they work on every system I use.
On 13 Mar 15:53, Chris G wrote:
On Fri, Mar 13, 2009 at 09:40:22AM +0000, steveydoteu wrote:
Chris, with your vast "experiences" you so often speak of, surely you would have found an alternate to the god awful use of chown and a wildcard expansion by now?
Like what? It's crude quick and simple but did basically what I needed in that particular case. Why try to be any cleverer?
if going for the lowest common denomitor, the use of shell globs would be thoroughly discouraged... not all shells glob, after all.
(And solaris' "/bin/sh" is actually made of shit, doesn't work anything like the standard says it should, and should therefore be killed as soon as possible).
Re my 'experience', a great deal of it is on old[ish] Solaris systems, and also various other (often old) varieties of Unix. I thus tend to go for "lowest common denominator" types of command because they work on every system I use.
/me 's experience appears to have so far covered Solaris, HP UX, Tru64, OS X Server (and I still haven't managed to work out why the hell anyone thinks that's a good idea), OpenVMS (hahahaha - I don't think I want to touch that again for a while), FreeBSD, OpenBSD, NetBSD and, at various points, most linux distributions...
find and xargs have been around for years and years and years - there's very little excuse to have not come across them...
I suppose that you also consistently use ps -ef rather than ps auxww?
Ho hum,
Hi
2009/3/13 Brett Parker iDunno@sommitrealweird.co.uk:
I suppose that you also consistently use ps -ef rather than ps auxww?
Pah! Real Linux people cat /dev/kmem and cast the bytes to the appropriate struct! All in their brain!
Interestingly, my ps aux does not differ from ps auxw. The unlimited width option certainly is different and nice.
Srdjan
On Fri, 13 Mar 2009 16:16:38 +0000 Brett Parker iDunno@sommitrealweird.co.uk allegedly wrote:
I suppose that you also consistently use ps -ef rather than ps auxww?
If, like me, you spent most of your time on System V, then ps -ef comes perfectly naturally. OTOH, if you grew up on BSD systems, ps auxww flows more naturally from the fingers. Aliases work.....
(I spent a lot of time on Solaris in the early to mid 90s. God I hate what Sun did to sendmail (as if sendmail wasn't bad enough). The default install didn't even understand MX records. Oh Joy (no not Bill).
Mick
---------------------------------------------------------------------
The text file for RFC 854 contains exactly 854 lines. Do you think there is any cosmic significance in this?
Douglas E Comer - Internetworking with TCP/IP Volume 1
http://www.ietf.org/rfc/rfc854.txt ---------------------------------------------------------------------
On Fri, Mar 13, 2009 at 08:04:01PM +0000, mbm wrote:
On Fri, 13 Mar 2009 16:16:38 +0000 Brett Parker iDunno@sommitrealweird.co.uk allegedly wrote:
I suppose that you also consistently use ps -ef rather than ps auxww?
If, like me, you spent most of your time on System V, then ps -ef comes perfectly naturally. OTOH, if you grew up on BSD systems, ps auxww flows more naturally from the fingers. Aliases work.....
I 'grew up' with "ps auxww" but a few years ago I found that "ps -ef" worked everywhere that I used but "ps auxww" didn't I standardised on "ps -ef". Occasionally "ps auxww" shows something that "ps -ef" doesn't but it's not often the difference matters.
(I spent a lot of time on Solaris in the early to mid 90s. God I hate what Sun did to sendmail (as if sendmail wasn't bad enough). The default install didn't even understand MX records. Oh Joy (no not Bill).
I used SunOs (nothing called Solaris way back then, at least not on the systems I worked on), then Solaris when it arrived, from about 1988 through to now.
Hi,
2009/3/13 steveydoteu alug@stevey.eu:
Chris, with your vast "experiences" you so often speak of, surely you would have found an alternate to the god awful use of chown and a wildcard expansion by now?
There's nothing terribly wrong with the command Chris posted. Sure, in nice circumstances, it will chown half your filesystem. :)
I did something similar once, as root. Wanted to chown hidden files, and did chown -R foouser:foogroup .* Sure, I realised my mistake, recovered the permissions. But I became a better user as a direct result.
Besides, what would *you* suggest, after the fact, now that you have flamed Chris? ;)
Srdjan