mulllhausen
mulllhausen

Reputation: 4435

linux check if file is contained within file

using linux, i have two binary files - TRA and TRF. TRA should be contained within TRF. how can i confirm this?

i have tried grep -vf TRA TRF

but it always says that it matches even when i am certain that it does not.

Upvotes: 1

Views: 63

Answers (1)

perreal
perreal

Reputation: 98118

You can convert the binary data into text then grep it:

od -A n -v -t x1 TRA | tr -d '\n' > TRA_HEX
od -A n -v -t x1 TRF | tr -d '\n' > TRF_HEX
if grep -f TRA_HEX TRF_HEX > /dev/null; then 
   echo "included"
fi

Upvotes: 1

Related Questions