[lug] Using Pipes w/ find exec Or find xargs

Jeffrey S. Haemer jeffrey.haemer at gmail.com
Tue Mar 24 16:30:52 MDT 2015


Like Louis, I may misunderstand the problem, but would some variant of this
work for you?

find / -type d | while read i; do echo $i | base64 -; done

Jeffrey Haemer <jeffrey.haemer at gmail.com>
720-837-8908 [cell], http://seejeffrun.blogspot.com [blog],
http://www.youtube.com/user/goyishekop [vlog]
*פרייהייט? דאס איז יאַנג דינען וואָרט.*

On Tue, Mar 24, 2015 at 3:59 PM, <stimits at comcast.net> wrote:

> Hi,
>
> I have the need to encode directory contents via base64 for a large number
> of files and directories. One choice is to produce one long string of file
> names and then later do the base64 encoding, separating each file name out
> of the string one at a time. This is easy, but very very slow in bash. Two
> other possibilities are to combine find with xargs -L 1 or with exec...and
> have the base64 be called on individual files. The base64 command itself
> handles random strings when provided by a pipe; unfortunately, there is no
> command line option to use base64 directly on standard input without pipes
> and echo.
>
> For a quick demo, one can do this minimal example of find without encoding
> to base64:
> find / -mindepth 1 -maxdepth 1 -type d -exec echo '{}' \;
>
> Or:
> find / -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -L 1
>
> So far though I've been unable to pipe this through base64 one file at a
> time; piping the whole string through base64 gives one long encoding and I
> need individual encodings for each file name. Something like this is
> needed, but fails:
> find / -mindepth 1 -maxdepth 1 -type d -print0 | `xargs -0 -L 1 | base64`
>
> Anyone here know how to use pipes with find and xargs or exec sending to
> base64 on a per file basis?
>
> Thanks!
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20150324/dfc8a92b/attachment.html>


More information about the LUG mailing list