broken pipe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



hello,

to avoid having to read twice the entire large file, I use the tee tool in
this way to calculate two checksums "simultaneously" :

file_info(){
    echo -n ${1:=/dev/stdin}$'\t'
    (
        tee < "${1}" \
            >( md5sum >&3 ) \
            >( sha1sum >&3 ) \
            >/dev/null
    ) 3>&1 |
    tr '\n' '\t'
    echo
}

it works perfectly because both tools used, md5sum and sha1sum, consume all
the data.

on the other hand, the function returns wrong fingerprints if I insert a
tool like file :

file_info(){
    echo -n ${1:=/dev/stdin}$'\t'
    (
        tee < "${1}" \
            >( file --mime-type -b -e compress -e tar -e elf - >&3 ) \
            >( md5sum >&3 ) \
            >( sha1sum >&3 ) \
            >/dev/null
    ) 3>&1 |
    tr '\n' '\t'
    echo
}

it no longer works because the data flow is quickly interrupted by tee
which does not consume all the data.

do you know a way to get the file type in parallel with the fingerprint ?

getting its type is just an example : the idea is to open the file only
once...

regards, lacsaP.



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux