Advertisement
Guest User

Untitled

a guest
Mar 20th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. for FILE_PATH; do
  4.     # read first 20 bytes from file and exctract 11th and 12th bytes as hexadecimal value:
  5.         HEAD_FLAGS="0x$(od -x -N20 "$FILE_PATH" | awk 'NR=1{print $7;exit}')"
  6.         VOLUME_FLAG="0x0001"
  7.         FIRST_FLAG="0x0100"
  8.  
  9.         if [ $(($HEAD_FLAGS&$VOLUME_FLAG)) -ne 0 ]; then # is volume
  10.                 if [ $(($HEAD_FLAGS&$FIRST_FLAG)) -ne 0 ]; then # is first volume
  11.                         echo "$FILE_PATH is the first volume"
  12.                 else
  13.                         echo "$FILE_PATH is NOT the first volume"
  14.                 fi
  15.         else # is regular, single rar archive
  16.                 echo "$FILE_PATH is a regular, single RAR-file"
  17.         fi
  18. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement