#!/bin/bash for FILE_PATH; do # read first 20 bytes from file and exctract 11th and 12th bytes as hexadecimal value: HEAD_FLAGS="0x$(od -x -N20 "$FILE_PATH" | awk 'NR=1{print $7;exit}')" VOLUME_FLAG="0x0001" FIRST_FLAG="0x0100" if [ $(($HEAD_FLAGS&$VOLUME_FLAG)) -ne 0 ]; then # is volume if [ $(($HEAD_FLAGS&$FIRST_FLAG)) -ne 0 ]; then # is first volume echo "$FILE_PATH is the first volume" else echo "$FILE_PATH is NOT the first volume" fi else # is regular, single rar archive echo "$FILE_PATH is a regular, single RAR-file" fi done