09-08-2011
split a string and convert to binary
Hi All,
Iam new to unix scripting and I want a split a string into 4 characters each, leaving the last two characters and convert the splitted values into binary.
For example:
string='ffd80012ffe20000ffebfffeffea0007fff0ffd70014fff1fff0fff0fff201'
this should split as
ffd8
0012
ffe2
.
.
.
fff2
leaving 01 and each value should be converted to binary
Please provide a shell script for this.
Thanks inadvance
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Here is what I did . . . . I FTP'd several *.pdf files from a web site to a UNIX server, and did not set the transfer mode to BIN, now Adobe thinks that the documents are corrupted. Is there a way to convert the *.pdf files to Binary so that Adobe can open them again. I would just re-download... (2 Replies)
Discussion started by: pc9456
2 Replies
2. UNIX for Advanced & Expert Users
Dear Experts
I need to read a binary file. I know for example in byte number 3801-3804 there is a 4 byte number embeded. Is there a way to extract this number from this file and then convert it to ascii via unix??
Your help would be highly appreciated.
Very Best Regards
Reza (5 Replies)
Discussion started by: Reza Nazarian
5 Replies
3. Programming
i hav tried to convert binary 2D data into text using binreader and writing into text file using streamwriter.
i use ReadSingle() function to convert from binary to ascii, although it works good in 1D data but not in more dimensions.
the kind of values i get are
-1.265369923E+038
and like
... (2 Replies)
Discussion started by: geet
2 Replies
4. Shell Programming and Scripting
Hi all,
I have a binary file (orig.dat) and two special delimiter strings 'AAA' and 'BBB'. My binary file's content is as follow:
<Data1.1>AAA<Data1.2>BBB
<Data2.1>AAA<Data2.2>BBB
...
<DataN.1>AAA<DataN.2>BBB
DataX.Y might have any length, and contains any kind of special/printable... (1 Reply)
Discussion started by: Averell
1 Replies
5. Shell Programming and Scripting
Hello!
Everytime when a specific binaryfile grows (in 4 byte steps) I want to get the newest 2 bytes immediately when they occur. That can be done by
tail -f binfile but I need the bytes in hex format. Therefore I use hexdump
tail -f binfile | hexdump -xwhat only prints out complete lines of... (6 Replies)
Discussion started by: maloe
6 Replies
6. Shell Programming and Scripting
Hello!
Have some problem with extract files from saved session.
File contains any kind of special/printable characters.
DATA NumberA DATA
DATA Begin
DATA1.1
DATA1.2 NumberB1 DATA1.3
DATA1.4
End DATA
DATA
DATA Begin
DATA2.1
DATA2.2 NumberB2 DATA2.3
DATA2.4
End DATA
DATA
... (4 Replies)
Discussion started by: vvild
4 Replies
7. UNIX for Dummies Questions & Answers
I would like to convert a .tr file to a binary file to use for trace purposes.
Can anyone provide any insight? (0 Replies)
Discussion started by: sparklezilla3
0 Replies
8. AIX
Hi
I need to display the binary text of an clearn text which is sent as input to the shell script (c shell);
ex: I will pass "HELLO" as input, and i should get the binary format of the text
Thanks in advance
Mohan (1 Reply)
Discussion started by: mKarri
1 Replies
9. Shell Programming and Scripting
Hello *nix specialists,
Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies
10. Solaris
I have a huge files in binary format
thanks to help me in finding a way to convert these files from Binary format to ASCII format. (0 Replies)
Discussion started by: PRINCESS_RORO
0 Replies
LEARN ABOUT PHP
sqlite_escape_string
SQLITE_ESCAPE_STRING(3) SQLITE_ESCAPE_STRING(3)
sqlite_escape_string - Escapes a string for use as a query parameter
SYNOPSIS
string sqlite_escape_string (string $item)
DESCRIPTION
sqlite_escape_string(3) will correctly quote the string specified by $item for use in an SQLite SQL statement. This includes doubling up
single-quote characters ( ') and checking for binary-unsafe characters in the query string.
Although the encoding makes it safe to insert the data, it will render simple text comparisons and LIKE clauses in your queries unusable
for the columns that contain the binary data. In practice, this shouldn't be a problem, as your schema should be such that you don't use
such things on binary columns (in fact, it might be better to store binary data using other means, such as in files).
PARAMETERS
o $item
- The string being quoted. If the $item contains a NUL character, or if it begins with a character whose ordinal value is 0x01,
PHP will apply a binary encoding scheme so that you can safely store and retrieve binary data.
RETURN VALUES
Returns an escaped string for use in an SQLite SQL statement.
NOTES
Note
Do not use this function to encode the return values from UDF's created using sqlite_create_function(3) or sqlite_create_aggre-
gate(3) - use sqlite_udf_encode_binary(3) instead.
Warning
addslashes(3) should NOT be used to quote your strings for SQLite queries; it will lead to strange results when retrieving your
data.
SEE ALSO
sqlite_udf_encode_binary(3).
PHP Documentation Group SQLITE_ESCAPE_STRING(3)