[opensuse] Re: Embedded Spaces in Pathnames
Carlos E. R. wrote:
On Friday, 2010-10-29 at 20:22 -0400, Lucky Leavell wrote:
On files/directories with no user, I want to change the user to nobody and likewise for the group. I could run the initial script twice, once to detect unowned files and the other to detect unowned groups and handle each separately. However, on some systems we have terabyte filesystems with millions of files and a single find command can run for days. Thus I would like to take this initial file and use that to correct both problems.
The problem I keep running into is with pathnames with embedded spaces. I have tried everything I can think of using shell scripts, awk and perl and they all have problems with pathnames with embedded spaces.
I simply write the names to a file, one file per line. Then a while loop reads them, one by one:
while read FILES ; do WorkOn "$FILES" done < $LISTOFFILES
This works neither for files with spaces nor for files with newlines in them. The former can be solved by setting IFS. The latter can be solved by not using Shell, but Perl or Python. Actually, my preferred way to solve that problem would be to execute find2perl / -nouser -o -nogroup >no-user-group.pl and then edit no-user-group.pl to add appropriate chown and chgrp actions. Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod Email: jschrod@acm.org Roedermark, Germany -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday, 2010-11-02 at 02:59 +0100, Joachim Schrod wrote:
Carlos E. R. wrote:
I simply write the names to a file, one file per line. Then a while loop reads them, one by one:
while read FILES ; do WorkOn "$FILES" done < $LISTOFFILES
This works neither for files with spaces nor for files with newlines in them.
Then explain how is it that I'm using it and it works, without touching IFS. I wrote a script this week to convert videos and they have several spaces. And it works fine... - -- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAkzQIbYACgkQtTMYHG2NR9X0vwCdHp7dofT/DpRgkmjPWWw1802Z sSgAnjcu19fk1j8RvFdVhyKROfy0u6m0 =FPcw -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
Carlos E. R.
-
Joachim Schrod