|
Prev: help with sort syntax
Next: Getting the greatest number
From: Steven Jones on 18 May 2006 14:47 Is it possible to send specific byte sequences from the shell command line to a file? Imagine I want to dump into a file the following byte sequence 04 11 32 7e 08 27 66 13 where each two digit group is the ASCII hex representation of a character. The problem is in the nonprintable characters. How can they be handled from the shell command line?
From: John W. Krahn on 18 May 2006 15:45 Steven Jones wrote: > Is it possible to send specific byte sequences from the shell command > line to a file? Imagine I want to dump into a file the following byte > sequence > > 04 11 32 7e 08 27 66 13 > > where each two digit group is the ASCII hex representation of a character. > The problem is in the nonprintable characters. How can they be handled > from the shell command line? perl -e'print "\x04\x11\x32\x7e\x08\x27\x66\x13"' > yourfile John -- use Perl; program fulfillment
From: Sven Mascheck on 18 May 2006 16:05 John W. Krahn wrote: > Steven Jones wrote: >> [...] send specific byte sequences from the shell command line > perl -e'print "\x04\x11\x32\x7e\x08\x27\x66\x13"' > yourfile printf '\x04\x11\x32\x7e\x08\x27\x66\x13' > John > use Perl; Sven type printf;
From: Chris F.A. Johnson on 18 May 2006 16:54 On 2006-05-18, Steven Jones wrote: > Is it possible to send specific byte sequences from the shell command > line to a file? Imagine I want to dump into a file the following byte > sequence > > 04 11 32 7e 08 27 66 13 > > where each two digit group is the ASCII hex representation of a character. > The problem is in the nonprintable characters. How can they be handled > from the shell command line? for c in 04 11 32 7e 08 27 66 13 do printf "%b" "\x$c" done -- Chris F.A. Johnson, author <http://cfaj.freeshell.org> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence
From: Daniel P. Valentine on 18 May 2006 19:42
In article <pan.2006.05.18.18.47.38.780527(a)sjones.org>, Steven Jones <sjones(a)sjones.org> wrote: > Is it possible to send specific byte sequences from the shell command > line to a file? Imagine I want to dump into a file the following byte > sequence > > 04 11 32 7e 08 27 66 13 > > where each two digit group is the ASCII hex representation of a character. > The problem is in the nonprintable characters. How can they be handled > from the shell command line? For a low-tech method assuming bash's echo, try echo -e "\x04\x11\x32\x7e\x08\x27\x66\x13" > yourfile The -e option tells it to interpret the \x sequences as the corresponding characters. -- dpv |