file /tmp/input.tcl
#! /usr/bin/env tclsh
fconfigure stdin -buffering none
set file [open "/tmp/output.txt" wb]
set data 0
while { $data >= 0 } {
set data [read stdin]
puts -nonewline $file $data
}
close $file
Делаю
cat /boot/amd-uc.img | /tmp/input.tcl
и получаю
$ md5sum /boot/amd-uc.img /tmp/output.txt
78b07920739329805bc25c8e67b73e2a /boot/amd-uc.img
4c67e69c409d2685fa9d2355c8253335 /tmp/output.txt
Хотя по смыслу вроде похожи
$ file /boot/amd-uc.img /tmp/output.txt
/boot/amd-uc.img: ASCII cpio archive (SVR4 with no CRC)
/tmp/output.txt: ASCII cpio archive (SVR4 with no CRC)
В какую сторону посмотреть?