39 lines
603 B
Bash
Executable File
39 lines
603 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ $# -lt 2 ]]
|
|
then
|
|
echo "Usage: $0 <display_format> <SCR_FILE>"
|
|
exit
|
|
fi
|
|
|
|
if [[ $1 != "1" && $1 != "2" ]]
|
|
then
|
|
echo "Unknown display format. Please submit 1 if no prefix, 2 for prefix U+"
|
|
exit
|
|
fi
|
|
|
|
if [[ ! -f $2 ]]
|
|
then
|
|
echo "File $2 doesn't exist or is not regular"
|
|
exit
|
|
fi
|
|
|
|
if [[ $1 == "2" ]]
|
|
then
|
|
fmt="U+"
|
|
fi
|
|
while read addr
|
|
do
|
|
l=$(expr length $addr)
|
|
ind=$(expr index $addr "0")
|
|
cont=$(expr substr $addr $((ind+1)) $((8-ind)))
|
|
pos=11
|
|
while [[ $pos -lt $l ]]
|
|
do
|
|
cont=$cont$(expr substr $addr $pos 6)
|
|
pos=$((pos+8))
|
|
done
|
|
printf "$fmt%x\n" $((2#$cont))
|
|
done < $2
|
|
exit
|