Hi, This might be a little O.t. so private responses please. I've got apache and samba running on a CentOS5 box enabling windows users to add web content. My issue is i've had to restore some backup data that was previously archived. The permissions aren't matching up so i'm wanting to use find and xargs to change them appropriately. Normally i do: find . -type type |xargs chmod value "{}"; which usually works. My issue is the files were made with spaces so find isn't able to find them. Does anyone have a workaround? Some urgency! Thanks. Dave.
Hi, This might be a little O.t. so private responses please. I've got apache and samba running on a CentOS5 box enabling windows users to add web content. My issue is i've had to restore some backup data that was previously archived. The permissions aren't matching up so i'm wanting to use find and xargs to change them appropriately. Normally i do: find . -type type |xargs chmod value "{}"; which usually works. My issue is the files were made with spaces so find isn't able to find them. Does anyone have a workaround? Some urgency!
try:
find . -type type -print0 | xargs -0 chmod value
-Shad
Hi, Thanks a lot. That did it. Dave.
----- Original Message ----- From: "Shad L. Lords" slords@lordsfam.net To: "CentOS mailing list" centos@centos.org Sent: Tuesday, November 20, 2007 1:19 PM Subject: Re: [CentOS] manipulating files and directories with spaces
Hi, This might be a little O.t. so private responses please. I've got apache and samba running on a CentOS5 box enabling windows users to add web content. My issue is i've had to restore some backup data that was previously archived. The permissions aren't matching up so i'm wanting to use find and xargs to change them appropriately. Normally i do: find . -type type |xargs chmod value "{}"; which usually works. My issue is the files were made with spaces so find isn't able to find them. Does anyone have a workaround? Some urgency!
try:
find . -type type -print0 | xargs -0 chmod value
-Shad _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Wednesday 21 November 2007 01:19:48 Shad L. Lords wrote:
try: find . -type type -print0 | xargs -0 chmod value
Thanks Shad. That was really cool. Reminds me to reading man pages more often :) -print0 True; print the full file name on the standard output, followed by a null character (instead of the newline character that ‘-print’ uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the ‘-0’ option of xargs.
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
Shad L. Lords wrote:
find . -type type -print0 | xargs -0 chmod value
Or (SUSV compliant):
find . -type f -exec chmod 123 {} +
Easier to type and more natural (for me). But less efficient than the xargs version since each file cause a new process to be spawned. For a very large number of items the difference would be noticeable.
Cheers,
Ralph
<snip sig stuff>
-- Bill
On Wed, 2007-11-21 at 04:39 -0500, William L. Maltby wrote:
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
find . -type f -exec chmod 123 {} +
Easier to type and more natural (for me). But less efficient than the xargs version since each file cause a new process to be spawned.
Wrong. + causes find to append as many items as possible.
On Wed, 2007-11-21 at 05:24 -0500, Ignacio Vazquez-Abrams wrote:
On Wed, 2007-11-21 at 04:39 -0500, William L. Maltby wrote:
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
find . -type f -exec chmod 123 {} +
Easier to type and more natural (for me). But less efficient than the xargs version since each file cause a new process to be spawned.
Wrong. + causes find to append as many items as possible.
Good grief! Learn something new every day. I guess I need to RTFM again every few years to see what's changed. :-P
<snip sig stuff>
-- Bill
William L. Maltby wrote:
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
Shad L. Lords wrote:
find . -type type -print0 | xargs -0 chmod value
Or (SUSV compliant):
find . -type f -exec chmod 123 {} +
Easier to type and more natural (for me). But less efficient than the xargs version since each file cause a new process to be spawned. For a very large number of items the difference would be noticeable.
Wrong.
-exec command {} + This variant of the -exec option runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invo- cations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of ’{}’ is allowed within the command. The command is executed in the starting directory.
And yes, that works on mostly any Unix (as said: SUSV compliant), while many commercial unixes have "interesting" implementations of xargs and -print0 (or don't have that at all).
Cheers,
Ralph
In article 20071121102709.GH12494@br-online.de, Ralph Angenendt ra+centos@br-online.de wrote:
William L. Maltby wrote:
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
Shad L. Lords wrote:
find . -type type -print0 | xargs -0 chmod value
Or (SUSV compliant):
find . -type f -exec chmod 123 {} +
Easier to type and more natural (for me). But less efficient than the xargs version since each file cause a new process to be spawned. For a very large number of items the difference would be noticeable.
Wrong.
-exec command {} + This variant of the -exec option runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invo- cations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of {} is allowed within the command. The command is executed in the starting directory.
And yes, that works on mostly any Unix (as said: SUSV compliant), while many commercial unixes have "interesting" implementations of xargs and -print0 (or don't have that at all).
Maybe, but unless it works on CentOS 5, it is irrelevant to this list. It certainly is not available in the "find" on CentOS 4:
[root@hostname ~]# find /home/user/ -type f -exec echo {} + : find: missing argument to `-exec' [root@hostname ~]#
Cheers Tony
On Wed, Nov 21, 2007 at 10:45:12AM +0000, Tony Mountifield wrote: ...
Maybe, but unless it works on CentOS 5, it is irrelevant to this list.
it works on CentOS-5 (findutils-4.2.27-4.1)
It certainly is not available in the "find" on CentOS 4:
The request was specific on CentOS-5. What's you point?
[root@hostname ~]# find /home/user/ -type f -exec echo {} + : find: missing argument to `-exec'
you would have the syntax wrong: find /home/user/ -type f -exec echo {} +
but it's not available on CentOS-4 (findutils-4.1.20-7.el4.3) nor CentOS-3 (findutils-4.1.7-9.).
Cheers.
Tru
Tru Huynh wrote:
you would have the syntax wrong: find /home/user/ -type f -exec echo {} +
but it's not available on CentOS-4 (findutils-4.1.20-7.el4.3) nor CentOS-3 (findutils-4.1.7-9.).
Yeah, gnu tools sometimes seem very late when it comes to adopting standards :)
Cheers,
Ralph
In article 1195638046.5747.31.camel@centos01.homegroannetworking, William L. Maltby CentOS4Bill@triad.rr.com wrote:
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
Shad L. Lords wrote:
find . -type type -print0 | xargs -0 chmod value
Or (SUSV compliant):
find . -type f -exec chmod 123 {} +
P.S.
Don't forget to escape the "{" and "}".
Why? I've never needed to.
Cheers Tony
On Wed, 2007-11-21 at 10:46 +0000, Tony Mountifield wrote:
In article 1195638046.5747.31.camel@centos01.homegroannetworking, William L. Maltby CentOS4Bill@triad.rr.com wrote:
On Wed, 2007-11-21 at 10:04 +0100, Ralph Angenendt wrote:
Shad L. Lords wrote:
find . -type type -print0 | xargs -0 chmod value
Or (SUSV compliant):
find . -type f -exec chmod 123 {} +
P.S.
Don't forget to escape the "{" and "}".
Why? I've never needed to.
Well, for a *long* time, the shell would react to them. Does it still? I don't know. But on this machine
$ lsb_release -a LSB Version: :core-3.0-ia32:core-3.0-noarch:graphics-3.0- ia32:graphics-3.0-noarch Distributor ID: CentOS Description: CentOS release 4.5 (Final) Release: 4.5 Codename: Final
$ rpm -q findutils findutils-4.1.20-7.el4.3.i386
<partial quote from "man find> ... All following arguments to find are taken to be arguments to the command until an argument consisting of ';' is encountered. ... Both of these constructions might need to be escaped (with a '') or quoted to protect them from expansion by the </partial quote from "man find>
Since I'm an old user with old habits (which, as we know, die hard), I still put them in, along with the ';' at the end. If I get really energetic (or maybe it's lazy?) I might invest the time and energy to experiment and see what works here. Of course, then I'm setting myself up to forget whether I'm on CentOS 4 or 5 (I don't use my 5 much yet) or LFS or ... :-(
I think I'll stick with what works more "universally".
Cheers Tony
-- Bill
--On Tuesday, November 20, 2007 1:14 PM -0500 Dave dmehler26@woh.rr.com wrote:
My issue is the files were made with spaces so find isn't able to find them.
Good to know about the -print0 trick.
My rule of thumb is that when I see a space in a filename, that's a clue that a directory is likely needed to group content together. Not necessarily true for end users, but almost always true in my programming work. Just as spaces provide semantic boundaries in natural language, directory separators provide such boundaries in filesystem organization.
For example, instead of creating a folder named "my company's photos for 2007", I'd create "Company/Photos/2007".
My office is a mess, but my disk stays highly organized. ;)