Discussion:
Embedded Spaces in Pathnames
(too old to reply)
Carlos E. R.
2010-10-30 12:16:04 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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

Calling commands with enclosed "$FILES" variable works with spaces.
However, you would still traverse the list twice at least, because the
attributes are not stored that way, only the names.

You could use find with xargs, but you still have to access the disk
several times.

- --
Cheers,
Carlos E. R.
(from 11.2 x86_64 "Emerald" at Telcontar)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)

iEYEARECAAYFAkzMDIYACgkQtTMYHG2NR9WBhwCfTISuBAAlNKnYACWtdvZsOY97
iqwAoIaU6C84WCExp1DekC4f6LDabjut
=5Tt6
-----END PGP SIGNATURE-----
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Randall R Schulz
2010-10-30 17:07:50 UTC
Permalink
Post by Carlos E. R.
...
I simply write the names to a file, one file per line. Then a while
while read FILES ; do
WorkOn "$FILES"
done < $LISTOFFILES
I may be remembering the defaults incorrectly, but I'd reset IFS just to
be sure spaces don't break the parse:

IFS=
while read targetFile; do
# Do stuff with the file whose name is held in "$targetFile"
done <"fileListfile"
Post by Carlos E. R.
Calling commands with enclosed "$FILES" variable works with spaces.
However, you would still traverse the list twice at least, because
the attributes are not stored that way, only the names.
You could use find with xargs, but you still have to access the disk
several times.
Yes and no. In reality, the data structures holding the file system
information will be cached by the kernel and making multiple passes
over them has fairly low overhead.
Post by Carlos E. R.
--
Cheers,
Carlos E. R.
Randall Schulz
--
To unsubscribe, e-mail: opensuse+***@opensuse.org
For additional commands, e-mail: opensuse+***@opensuse.org
Loading...