#!/bin/bash checkGMAD() { header=$(head -c4 $1 | xxd -ps) echo "'$header'" if [[ "$header" = "474d4144" ]]; then return 0 else return 1 fi } checkLZMA() { header=$(cat $1 | lzma -d - | head -c4 | xxd -ps) if [[ "$header" = "474d4144" ]]; then return 0 else return 1 fi } testNfix() { file=$1 if checkGMAD "$file"; then echo "file is native GMAD" else if checkLZMA "$file"; then echo "file is lzma'd GMAD" cat "$file" | lzma -d > "$file.unc" if checkGMAD "$file.unc"; then mv "$file" "$file.lzma" && mv "$file.unc" "$file" && echo "file has been converted to GMAD" && exit 0 else echo "file couldn't be converted" fi rm "$file.unc" else echo "file is somewhat else" fi fi }