Tag Info

New answers tagged


You can do: LC_ALL=C tr '\0-\377' ...


Another perl: $ perl -pe '$_ = pack("i", $_)' file i represents signed integer value (which is represent at least 4 bytes, depend on local C compiler). Use l option like @St├ęphane Chazelas's answer for always use 32-bit.


perl -pe '$_=pack"l",$_' < infile > outfile Uses the local endianness. Use l> instead of l for big-endian, and l< for little-endian. See perldoc -f pack for more info. Note that it's l as in lowercase L (for long integer), not the 1 digit. $ printf '%s\n' 1234 -2 | perl -pe '$_=pack"l",$_'| od -vtd4 0000000 1234 -2 0000010 $ ...

Top 50 recent answers are included