Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Mar 20th, 2013  |  syntax: Bash  |  size: 0.70 KB  |  hits: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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