01-19-2015
A starter idea longhand OSX 10.7.5 default bash terminal.
A pure flat file only as we have no idea of the layout...
ALL values below decimal 32 and above 126 not converted...
Code :
#!/bin/bash
# binparse
ifs_str="$IFS"
IFS=""
ascii=""
while read -s -d '' -r -n 1 char
do
num=$(printf "%d" "'$char")
if [ $num -ge 32 ] && [ $num -le 126 ]
then
ascii=$ascii$char
fi
done < ~/Desktop/file.bin # Your binary file...
IFS="$ifs_str"
echo "$ascii"
exit 0
Results from you file snippet...
Code :
Last login: Mon Jan 19 20:08:15 on ttys000
AMIGA:barrywalker~> cd Desktop
AMIGA:barrywalker~/Desktop> cd Code
AMIGA:barrywalker~/Desktop/Code> cd Shell
AMIGA:barrywalker~/Desktop/Code/Shell> ./binparse
00002F6D00002F5S00002F6800002F6J00002F6800002F5P00002F6HBREAK00000BZ4Generique_debut_19_20100002F6LTR1_MANIF_MONTPELLIER300002F6MTR2_ST_LAURENT_LE_MINIER400002F6NTR3_JEANE_MANSON500002F5ZS_DOUBLE_MANIF_MONTPELLIER700002F60S_DEBAT_AGORA_LA_PAILLADE900002F5U%M_OFF_GREVE_CHAUFFEURS_ROUTIERS_0_22_1100002F6CS_OFF_USAP_0_23_1300002F5X!M_OFF_FOOT_METZ_MONTPELLIER_0_33_1700002F6OCARTE_ST_LAURENT_LE_MINIER1900002F61.ST_LAURENT_LE_MINIER_NETTOYAGE_RIVIERES_NIMES_2000002F21L_ECOFERME2200002F6PCARTE_AUMONT_AUBRAC_48_2400002F69LRM_2_ATTRAZIC_ET_VIGROUX2500002F6ALRM_JEANE_MANSON270000245KVoix_gene_fin_MIXEE_F3Regions_29BREAK00002F6K00002F5O00002F5T00002F6IBREAK
AMIGA:barrywalker~/Desktop/Code/Shell> _
EDIT:
This is a hexdump -C of the file...
Found the sections that newlines could be coded for...
The 4 examples are the length of each ASCII character block and 2 are ascii characters too!
I have not bothered to do the others but just look at the character before each __text__ block.
Code :
00000000 1e 00 14 00 00 00 ff fe ff 08 30 00 30 00 30 00 |..........0.0.0.|
00000010 30 00 32 00 46 00 36 00 44 00 ff fe ff 00 ff fe |0.2.F.6.D.......|
00000020 ff 00 ff fe ff 00 00 00 00 00 ff fe ff 08 30 00 |..............0.|
00000030 30 00 30 00 30 00 32 00 46 00 35 00 53 00 ff fe |0.0.0.2.F.5.S...|
00000040 ff 00 ff fe ff 00 ff fe ff 00 01 00 00 00 ff fe |................|
00000050 ff 08 30 00 30 00 30 00 30 00 32 00 46 00 36 00 |..0.0.0.0.2.F.6.|
00000060 38 00 ff fe ff 00 ff fe ff 00 ff fe ff 00 01 00 |8...............|
00000070 00 00 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 |......0.0.0.0.2.|
00000080 46 00 36 00 4a 00 ff fe ff 00 ff fe ff 00 ff fe |F.6.J...........|
00000090 ff 00 01 00 00 00 ff fe ff 08 30 00 30 00 30 00 |..........0.0.0.|
000000a0 30 00 32 00 46 00 36 00 38 00 ff fe ff 00 ff fe |0.2.F.6.8.......|
000000b0 ff 00 ff fe ff 00 01 00 00 00 ff fe ff 08 30 00 |..............0.|
000000c0 30 00 30 00 30 00 32 00 46 00 35 00 50 00 ff fe |0.0.0.2.F.5.P...|
000000d0 ff 00 ff fe ff 00 ff fe ff 00 01 00 00 00 ff fe |................|
000000e0 ff 08 30 00 30 00 30 00 30 00 32 00 46 00 36 00 |..0.0.0.0.2.F.6.|
000000f0 48 00 ff fe ff 00 ff fe ff 00 ff fe ff 00 01 00 |H...............|
00000100 00 00 ff fe ff 05 42 00 52 00 45 00 41 00 4b 00 |......B.R.E.A.K.|
00000110 ff fe ff 00 ff fe ff 00 ff fe ff 00 00 00 00 00 |................|
00000120 ff fe ff 08 30 00 30 00 30 00 30 00 30 00 42 00 |....0.0.0.0.0.B.|
00000130 5a 00 34 00 ff fe ff 00 ff fe ff 15 47 00 65 00 |Z.4.........G.e.|
00000140 6e 00 65 00 72 00 69 00 71 00 75 00 65 00 5f 00 |n.e.r.i.q.u.e._.|
00000150 64 00 65 00 62 00 75 00 74 00 5f 00 31 00 39 00 |d.e.b.u.t._.1.9.|
00000160 5f 00 32 00 30 00 ff fe ff 01 31 00 00 00 00 00 |_.2.0.....1.....|
00000170 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 46 00 |....0.0.0.0.2.F.|
00000180 36 00 4c 00 ff fe ff 00 ff fe ff 15 54 00 52 00 |6.L.........T.R.|
00000190 31 00 5f 00 4d 00 41 00 4e 00 49 00 46 00 5f 00 |1._.M.A.N.I.F._.|
000001a0 4d 00 4f 00 4e 00 54 00 50 00 45 00 4c 00 4c 00 |M.O.N.T.P.E.L.L.|
000001b0 49 00 45 00 52 00 ff fe ff 01 33 00 00 00 00 00 |I.E.R.....3.....|
000001c0 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 46 00 |....0.0.0.0.2.F.|
000001d0 36 00 4d 00 ff fe ff 00 ff fe ff 18 54 00 52 00 |6.M.........T.R.|
000001e0 32 00 5f 00 53 00 54 00 5f 00 4c 00 41 00 55 00 |2._.S.T._.L.A.U.|
000001f0 52 00 45 00 4e 00 54 00 5f 00 4c 00 45 00 5f 00 |R.E.N.T._.L.E._.|
00000200 4d 00 49 00 4e 00 49 00 45 00 52 00 ff fe ff 01 |M.I.N.I.E.R.....|
00000210 34 00 00 00 00 00 ff fe ff 08 30 00 30 00 30 00 |4.........0.0.0.|
00000220 30 00 32 00 46 00 36 00 4e 00 ff fe ff 00 ff fe |0.2.F.6.N.......|
00000230 ff 10 54 00 52 00 33 00 5f 00 4a 00 45 00 41 00 |..T.R.3._.J.E.A.|
00000240 4e 00 45 00 5f 00 4d 00 41 00 4e 00 53 00 4f 00 |N.E._.M.A.N.S.O.|
00000250 4e 00 ff fe ff 01 35 00 00 00 00 00 ff fe ff 08 |N.....5.........|
00000260 30 00 30 00 30 00 30 00 32 00 46 00 35 00 5a 00 |0.0.0.0.2.F.5.Z.|
00000270 ff fe ff 00 ff fe ff 1a 53 00 5f 00 44 00 4f 00 |........S._.D.O.|
00000280 55 00 42 00 4c 00 45 00 5f 00 4d 00 41 00 4e 00 |U.B.L.E._.M.A.N.|
00000290 49 00 46 00 5f 00 4d 00 4f 00 4e 00 54 00 50 00 |I.F._.M.O.N.T.P.|
000002a0 45 00 4c 00 4c 00 49 00 45 00 52 00 ff fe ff 01 |E.L.L.I.E.R.....|
000002b0 37 00 00 00 00 00 ff fe ff 08 30 00 30 00 30 00 |7.........0.0.0.|
000002c0 30 00 32 00 46 00 36 00 30 00 ff fe ff 00 ff fe |0.2.F.6.0.......|
000002d0 ff 19 53 00 5f 00 44 00 45 00 42 00 41 00 54 00 |..S._.D.E.B.A.T.|
000002e0 5f 00 41 00 47 00 4f 00 52 00 41 00 5f 00 4c 00 |_.A.G.O.R.A._.L.|
000002f0 41 00 5f 00 50 00 41 00 49 00 4c 00 4c 00 41 00 |A._.P.A.I.L.L.A.|
00000300 44 00 45 00 ff fe ff 01 39 00 00 00 00 00 ff fe |D.E.....9.......|
00000310 ff 08 30 00 30 00 30 00 30 00 32 00 46 00 35 00 |..0.0.0.0.2.F.5.|
00000320 55 00 ff fe ff 00 ff fe ff 25 4d 00 5f 00 4f 00 |U........%M._.O.|
00000330 46 00 46 00 5f 00 47 00 52 00 45 00 56 00 45 00 |F.F._.G.R.E.V.E.|
00000340 5f 00 43 00 48 00 41 00 55 00 46 00 46 00 45 00 |_.C.H.A.U.F.F.E.|
00000350 55 00 52 00 53 00 5f 00 52 00 4f 00 55 00 54 00 |U.R.S._.R.O.U.T.|
00000360 49 00 45 00 52 00 53 00 5f 00 30 00 5f 00 32 00 |I.E.R.S._.0._.2.|
00000370 32 00 5f 00 ff fe ff 02 31 00 31 00 00 00 00 00 |2._.....1.1.....|
00000380 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 46 00 |....0.0.0.0.2.F.|
00000390 36 00 43 00 ff fe ff 00 ff fe ff 10 53 00 5f 00 |6.C.........S._.|
000003a0 4f 00 46 00 46 00 5f 00 55 00 53 00 41 00 50 00 |O.F.F._.U.S.A.P.|
000003b0 5f 00 30 00 5f 00 32 00 33 00 5f 00 ff fe ff 02 |_.0._.2.3._.....|
000003c0 31 00 33 00 00 00 00 00 ff fe ff 08 30 00 30 00 |1.3.........0.0.|
000003d0 30 00 30 00 32 00 46 00 35 00 58 00 ff fe ff 00 |0.0.2.F.5.X.....|
000003e0 ff fe ff 21 4d 00 5f 00 4f 00 46 00 46 00 5f 00 |...!M._.O.F.F._.|
000003f0 46 00 4f 00 4f 00 54 00 5f 00 4d 00 45 00 54 00 |F.O.O.T._.M.E.T.|
00000400 5a 00 5f 00 4d 00 4f 00 4e 00 54 00 50 00 45 00 |Z._.M.O.N.T.P.E.|
00000410 4c 00 4c 00 49 00 45 00 52 00 5f 00 30 00 5f 00 |L.L.I.E.R._.0._.|
00000420 33 00 33 00 5f 00 ff fe ff 02 31 00 37 00 00 00 |3.3._.....1.7...|
00000430 00 00 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 |......0.0.0.0.2.|
00000440 46 00 36 00 4f 00 ff fe ff 00 ff fe ff 1a 43 00 |F.6.O.........C.|
00000450 41 00 52 00 54 00 45 00 5f 00 53 00 54 00 5f 00 |A.R.T.E._.S.T._.|
00000460 4c 00 41 00 55 00 52 00 45 00 4e 00 54 00 5f 00 |L.A.U.R.E.N.T._.|
00000470 4c 00 45 00 5f 00 4d 00 49 00 4e 00 49 00 45 00 |L.E._.M.I.N.I.E.|
00000480 52 00 ff fe ff 02 31 00 39 00 00 00 00 00 ff fe |R.....1.9.......|
00000490 ff 08 30 00 30 00 30 00 30 00 32 00 46 00 36 00 |..0.0.0.0.2.F.6.|
000004a0 31 00 ff fe ff 00 ff fe ff 2e 53 00 54 00 5f 00 |1.........S.T._.|
000004b0 4c 00 41 00 55 00 52 00 45 00 4e 00 54 00 5f 00 |L.A.U.R.E.N.T._.|
000004c0 4c 00 45 00 5f 00 4d 00 49 00 4e 00 49 00 45 00 |L.E._.M.I.N.I.E.|
000004d0 52 00 5f 00 4e 00 45 00 54 00 54 00 4f 00 59 00 |R._.N.E.T.T.O.Y.|
000004e0 41 00 47 00 45 00 5f 00 52 00 49 00 56 00 49 00 |A.G.E._.R.I.V.I.|
000004f0 45 00 52 00 45 00 53 00 5f 00 4e 00 49 00 4d 00 |E.R.E.S._.N.I.M.|
00000500 45 00 53 00 5f 00 ff fe ff 02 32 00 30 00 00 00 |E.S._.....2.0...|
00000510 00 00 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 |......0.0.0.0.2.|
00000520 46 00 32 00 31 00 ff fe ff 00 ff fe ff 0a 4c 00 |F.2.1.........L.|
00000530 5f 00 45 00 43 00 4f 00 46 00 45 00 52 00 4d 00 |_.E.C.O.F.E.R.M.|
00000540 45 00 ff fe ff 02 32 00 32 00 00 00 00 00 ff fe |E.....2.2.......|
00000550 ff 08 30 00 30 00 30 00 30 00 32 00 46 00 36 00 |..0.0.0.0.2.F.6.|
00000560 50 00 ff fe ff 00 ff fe ff 17 43 00 41 00 52 00 |P.........C.A.R.|
00000570 54 00 45 00 5f 00 41 00 55 00 4d 00 4f 00 4e 00 |T.E._.A.U.M.O.N.|
00000580 54 00 5f 00 41 00 55 00 42 00 52 00 41 00 43 00 |T._.A.U.B.R.A.C.|
00000590 5f 00 34 00 38 00 5f 00 ff fe ff 02 32 00 34 00 |_.4.8._.....2.4.|
000005a0 00 00 00 00 ff fe ff 08 30 00 30 00 30 00 30 00 |........0.0.0.0.|
000005b0 32 00 46 00 36 00 39 00 ff fe ff 00 ff fe ff 19 |2.F.6.9.........|
000005c0 4c 00 52 00 4d 00 5f 00 32 00 5f 00 41 00 54 00 |L.R.M._.2._.A.T.|
000005d0 54 00 52 00 41 00 5a 00 49 00 43 00 5f 00 45 00 |T.R.A.Z.I.C._.E.|
000005e0 54 00 5f 00 56 00 49 00 47 00 52 00 4f 00 55 00 |T._.V.I.G.R.O.U.|
000005f0 58 00 ff fe ff 02 32 00 35 00 00 00 00 00 ff fe |X.....2.5.......|
00000600 ff 08 30 00 30 00 30 00 30 00 32 00 46 00 36 00 |..0.0.0.0.2.F.6.|
00000610 41 00 ff fe ff 00 ff fe ff 10 4c 00 52 00 4d 00 |A.........L.R.M.|
00000620 5f 00 4a 00 45 00 41 00 4e 00 45 00 5f 00 4d 00 |_.J.E.A.N.E._.M.|
00000630 41 00 4e 00 53 00 4f 00 4e 00 ff fe ff 02 32 00 |A.N.S.O.N.....2.|
00000640 37 00 00 00 00 00 ff fe ff 08 30 00 30 00 30 00 |7.........0.0.0.|
00000650 30 00 32 00 34 00 35 00 4b 00 ff fe ff 00 ff fe |0.2.4.5.K.......|
00000660 ff 1e 56 00 6f 00 69 00 78 00 5f 00 67 00 65 00 |..V.o.i.x._.g.e.|
00000670 6e 00 65 00 5f 00 66 00 69 00 6e 00 5f 00 4d 00 |n.e._.f.i.n._.M.|
00000680 49 00 58 00 45 00 45 00 5f 00 46 00 33 00 52 00 |I.X.E.E._.F.3.R.|
00000690 65 00 67 00 69 00 6f 00 6e 00 73 00 5f 00 ff fe |e.g.i.o.n.s._...|
000006a0 ff 02 32 00 39 00 00 00 00 00 ff fe ff 05 42 00 |..2.9.........B.|
000006b0 52 00 45 00 41 00 4b 00 ff fe ff 00 ff fe ff 00 |R.E.A.K.........|
000006c0 ff fe ff 00 00 00 00 00 ff fe ff 08 30 00 30 00 |............0.0.|
000006d0 30 00 30 00 32 00 46 00 36 00 4b 00 ff fe ff 00 |0.0.2.F.6.K.....|
000006e0 ff fe ff 00 ff fe ff 00 00 00 00 00 ff fe ff 08 |................|
000006f0 30 00 30 00 30 00 30 00 32 00 46 00 35 00 4f 00 |0.0.0.0.2.F.5.O.|
00000700 ff fe ff 00 ff fe ff 00 ff fe ff 00 01 00 00 00 |................|
00000710 ff fe ff 08 30 00 30 00 30 00 30 00 32 00 46 00 |....0.0.0.0.2.F.|
00000720 35 00 54 00 ff fe ff 00 ff fe ff 00 ff fe ff 00 |5.T.............|
00000730 01 00 00 00 ff fe ff 08 30 00 30 00 30 00 30 00 |........0.0.0.0.|
00000740 32 00 46 00 36 00 49 00 ff fe ff 00 ff fe ff 00 |2.F.6.I.........|
00000750 ff fe ff 00 01 00 00 00 ff fe ff 05 42 00 52 00 |............B.R.|
00000760 45 00 41 00 4b 00 ff fe ff 00 ff fe ff 00 ff fe |E.A.K...........|
00000770 ff 00 00 00 00 00 |......|
00000776
Last edited by wisecracker; 01-19-2015 at 06:09 PM ..
Reason: See above...
This User Gave Thanks to wisecracker For This Post:
10 More Discussions You Might Find Interesting
1. Solaris
Hi,
I have two Solaris machines.
1. SunOS X 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Blade-1500
2. SunOS Y 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60
I am trying to buiild a project on both these machines. The Binary output file compiled on machine 2 runs on both the machines. Where... (0 Replies)
Discussion started by: scgupta
0 Replies
2. Filesystems, Disks and Memory
I just started using Terminal on my Mac this summer, and right now I am having problems making a shell script. This shell should run the "Microsoft Setup Assistant" once I run the Automator Script. Alas, I still have problems.
Here is the offending scriptlet:
Sudo Tcsh
root# cd... (2 Replies)
Discussion started by: chrisfrap
2 Replies
3. Solaris
I tried to decode a binary script using the command 'uudecode'. but it is giving error as 'No begining line'.
'uudecode -o <outfile name> <binary file>'
Please help me in resolving this. (4 Replies)
Discussion started by: vamshikrishnab
4 Replies
4. SCO
Hi
I am looking for sco xenix binary compatibility utility "cvtomf",(convert omf object to COFF object)
Would you please help me ?
tnx (3 Replies)
Discussion started by: javad1_maroofi
3 Replies
5. UNIX for Dummies Questions & Answers
I am using grep to match a pattern, but the output is strange.
$ grep -r -o "pattern" *
Gives me:
Binary file foo1 matches
Binary file foo2 matches
Binary file foo3 matches
To find the lines before/after, I then have to use the following on each file:
$ strings foo1 | grep -A1 -B1... (0 Replies)
Discussion started by: chipperuga
0 Replies
6. Shell Programming and Scripting
I am struck up with a problem and that is with output redirection.
I used all the ways for the redirection of the output of c binary to a file, still it is failing.
Here are the different ways which I have used:
./a.out | tee -a /root/tmp.txt 2>&1
./a.out | tee -a /root/tmp.txt 1>&1
./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies
7. UNIX for Dummies Questions & Answers
Hello guys,
We had to move from a DC to another, and we are now facing an "issue" with some text files.
Looks like that some of our log files are set as binary:
file TuxConnectorURA.20121012
TuxConnectorURA.20121012: data or International Language text
less TuxConnectorURA.20121012... (2 Replies)
Discussion started by: EnioMarques
2 Replies
8. 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
9. Shell Programming and Scripting
I have a binary file with all content is text, i want convert this binary to a regular file because i want to parse it.
Thx.
---------- Post updated at 05:01 AM ---------- Previous update was at 04:34 AM ----------
I have found the solution
cat file | tr -d '\0' (8 Replies)
Discussion started by: protocomm
8 Replies
10. Web Development
Database Structure
Root Table
ID Root_ Node Level
1 A 0
2 B 1
3 C 1
Child Table
ID Left_Node Right_Node Root_Node Root_ID
1 B C A 1
... (1 Reply)
Discussion started by: Deepak Tiwari
1 Replies