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

Louis Krupp louis.krupp at gmail.com
Tue Mar 24 16:26:39 MDT 2015

Just to make sure we're all trying to solve the same problem, could you
post the easy bash solution?


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/5cfcdd70/attachment.html>

More information about the LUG mailing list