What I want is to take an integer represented as a string, for example "1234", and convert it to a file named int, containing a 32-bit integer with a large number, with a value of 1234.
The only way I decided to do this is something like
echo 1234 | awk '{printf "0: %08X", $1}' | xxd -r > int
which is a little nasty!
Does anyone know a better way?
ok seeing well that the williams sign seems to have passed awol, I will post a revised version of his answer
echo 1234 | perl -e 'print pack("N", <STDIN>); > int
Somewhat simpler:
printf "0: %08X" 1234 | xxd -r > int
, . perldoc -f pack.
perldoc -f pack
echo '1234' | perl -e 'print pack("nn", 0,<STDIN>);' > int