3 ms·
You can actually do what you want with piping: find . -print0 | grep -z '.*.jpg$' | xargs -0 gfxcompress
by heinrich5991 10y ago
You can actually do what you want with piping:
find . -print0 | grep -z '.*.jpg$' | xargs -0 gfxcompress
- saurik 10y ago(-0n1 likely, as it sounded from the example like gfxcompress is designed to operate only on one item at a time.) To make this explicit for readers: find, grep, and xargs actually already has the requested feature of "good human readable output in one mode, and [] structured, already escaped data [] in another mode", through -print0, -z, and -0, which also works great when combined with read -rd $'\0'.
- J_Darnley 10y agoOn this point of using a null char to separate things: do you people think that automatically using it when I/O is not connected to a terminal is a good idea?
- LukeShu 10y agoSort of. Obviously, for a great many tools that wouldn't be an option because it would break compatibility for scripts that have been running for decades. And \0 isn't necessarily a safe delimiter for all types of lists. But, for lists of file names (and other strings that cannot contain \0), yes, I believe that automatically using it when stdout is not connected to a terminal would be a reasonably good idea.
- continuational 10y agoCode point 0 / ASCII symbol number 0 is valid in ASCII and Unicode strings, so it simply can't be used for termination.