3 ms·
In the case of gzip -9 < /dev/random | dd of=/tmp/gibberish the shell's not actually doing anything but forking things and connecting file descriptors of pr
by cduzz 3y ago
In the case of
gzip -9 < /dev/random | dd of=/tmp/gibberish
the shell's not actually doing anything but forking things and connecting file descriptors of processes to each other
gzip -9 < /dev/random | while read line ; do echo "$line" ; done > /tmp/gibberish
The stdout of gzip is being processed by shell, and will make all the nulls go away.
(edited to add another example:)
Similarly - it isn't printing that you can't do -- it's anything -- consider:
case $(cat /bin/sh)
in
$(cat /bin/bash)) echo "they're the same!" ;;
*) echo "they're not the same!" ;;
esac
This is obviously an insane way to see if two files are identical, but worse -- it's going to fail for two different files whose only difference is how many nulls are in the file.