User:Wfpokorny/DensityFile/df3XYZsizeBashExample
Jump to navigation
Jump to search
The following bash script will run on many operating systems. Place the lines between the two "cut here" lines into a file called df3xyzsize.sh and save it.
Run it, for example, with the command:
bash df3xyzsize.sh spiral.df3
which should output the lines:
50 50 5
assuming the spiral.df3 is that shipped with POV-Ray.
----------------------------------------------- cut here ------------------------------------------ #!/bin/bash #---------------------------------------------- # Convert the first 6 bytes of df3 file to a hex string which is # then cut into three parts corresponding to the three unsigned, two # byte integers. Each of these four character hex strings is then # converted to an integer value and returned in x, y, z order. #---------------------------------------------- echo $((16#`head -c 6 $1 | xxd -p | head -c 4`)) echo $((16#`head -c 6 $1 | xxd -p | tail -c 9 | head -c 4`)) echo $((16#`head -c 6 $1 | xxd -p | tail -c 5 | head -c 4`)) exit 0 ----------------------------------------------- cut here ------------------------------------------