bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: du --files-from feature request


From: Eric Blake
Subject: Re: du --files-from feature request
Date: Sun, 07 Dec 2008 07:17:14 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081105 Thunderbird/2.0.0.18 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[Please keep the list in the loop, and please don't top-post]

According to Aaron Peterson on 12/7/2008 3:35 AM:
> Yes, scripts can be made. I'm pretty much sure that the guy on the
> debian list was planning to manually prune the files listed. I just
> realized that his desire to edit the list is ultimately screwed even
> futher by the possibility of newline being in the filename, and se
> 
> I just realized Padriags solution is limited to just the line count
> because it nukes all \ns!!!!!
> 
> If I need to convert between \0 and \n for programs I have to go thru
> all of this rigamorol:
> 
> Solution for the edit ability option would then be  to translate all
> \n to \\n AND  \0s to \\n\n then do the line by line operation, then
> convert all \\n\ns back to \0
> but I have a hunch that that won't work because what if  \\\\n\n\n
> is my literal filename?!
> so I am also going to have to do \\n to \\\\n.

No, if you want to be able to handle \n in filenames, then you merely need
generate the list with NUL separators to begin with.

> 
> So,
> 
> find -iname "*" -type f -0 | tr \\n \\\\n | tr \n \\n | tr \0 \\n\n |
> editor that takes from stdin and writes to stdout | linecount program
> |  tr \\n\n \0 | tr \\n \n | tr \\\\n \\n | du --files0-from -

find does not have a -0 option.  GNU findutils, however, provides a
- -print0 option.  And if you are using it, then the output is ALREADY
NUL-terminated and newlines are no longer a problem; you don't need to add
tr in the mix, and you don't need to worry about newlines or about literal
backslashes followed by n.  Anyway, 'tr \\n \\\\n' does not do what you
think - there is no way to make tr cause character sequences in the
original expand to even more characters in the replacement; you need sed
for that.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk72uoACgkQ84KuGfSFAYB21gCgm5DpIghscI9LTS+V1HxfsXtJ
5gsAn1cjjFF8hL7f8Jd8NLY6MoL+u7G8
=dWWB
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]