[Solved] Trimming out segment


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Trimming out segment
# 1  
Old 02-12-2014
[Solved] Trimming out segment

I have a file with a combination of binary characters and words, and need to trim out the segment i.e.
HTML Code:
SleeperThreadAborting {{username::RAB2002}} {{scriptname::scs_get_pending_by_loc}}
and put the lists into a text file.

Luckily, the segment I am looking for i.e. has readable words
HTML Code:
SleeperThreadAborting^G{{username::RAB2002}}{{scriptname::scs_get_pendi
ng_by_loc}}
with an extra binary
HTML Code:
^G
.

Please note that some have "carriage return" on i.e.
HTML Code:
{{scriptname::scs_get_pendi
ng_by_loc}}
Please advise.

HTML Code:
1_0//265088 ðB*¨0F±p0o×M-^@ðQM-^IM-^HÐ^_ã^P0o×00o× ðAæ<182071208/274991/273036ðB*¨01µ 0o×À^D^E
ÓM-^HUÀ^CðAæ^C0o×ÀSleeperThreadAborting^G{{username::RAB2002}}{{scriptname::scs_get_pendi
ng_by_loc}}0F§M-^HðAæ^Bñ^F×Ø0Fµ0M-^FM-^] 0oØ`ðQM-^EÐÐ^_» ^CðR    90F±x0oØ`ðR     ÓM-^E¬ð0oØ°0oØpñ
^G(T0oÙ<^AðQM-^EÐðQM-^IÄ0B^P0oÙ<01µ(0oØ ñ^FÙM-^HÓM-^E¬ð0oØàñ^G(TÐ^_ãÄ^A^V0Fµ^D^A0oØà^P  M-^HÔ0oÙ,0
oØà^T^M^A^L^G^B^U[RAB2002] - [root]°ðR   galaxy/377126/5912ðQM-^ISRV0051_10_0//265088 ðB*¨
0FÀM-^@0pM-^GM-^@ðQM-^IM-^HÐ^_ã^P0pM-^G00pM-^G ðAæ<182071208/274991/273036ðB*¨01ÇM-^P0pM-^GÀ^D^EÓM-^HUÀ^CðAæ
^C0pM-^GÀSleeperThreadAborting^G{{username::RAB2002}}{{scriptname::scs_get_pending_by_loc
}}0EM-^]èðAæ^Bñ^F×Ø0u~à0¤
^P0pM-^H`ðQM-^EÐÐ^_» ^CðR        90FÀM-^H0pM-^H`ðR       ÓM-^E¬ð0pM-^H°0pM-^Hpñ^G(T0pM-^I<^AðQM-^EÐðQM-^IÄ0B^P0pM-^I<0
1ÇM-^X0pM-^H ñ^FÙM-^HÓM-^E¬ð0pM-^Hàñ^G(TÐ^_ãÄ^A^V0u~ä^A0pM-^Hà^P        M-^HÔ0pM-^I,0pM-^Hà^T^M^A^L^G^B)[RAB20
02] - [root]°ðR  galaxy/1318948/5912ðQM-^ISRV0051_02_0//265088 ðB*¨0FZ00pWM-^@ðQM-^IM-^HÐ^_ã^P0p
W00pW ðAæ<182071208/274991/273036ðB*¨01¹^P0pWÀ^D^EÓM-^HUÀ^CðAæ^C0pWÀSleeperThreadAbortingæ^G{{username::RAB2002}}{{scriptname::scs_get_pending_by_loc}}0FhðAæ^Bñ^F×Ø0rïp0¢> 0pX`
ðQM-^EÐÐ^_» ^CðR         90FZ80pX`ðR     ÓM-^E¬ð0pX°0pXpñ^G(T0pY<^AðQM-^EÐðQM-^IÄ0B^P0pY<01¹^X0pX ñ^FÙ
 galaxy/889092/5912ðQM-^ISRV0051_03_0//265088 ðB*¨01Ë 0pM-^GM-^@ðQM-^IM-^HÐ^_ã^P0pM-^G00pM-^G ðAæ<1820
71208/274991/273036ðB*¨01¶0pM-^GÀ^D^EÓM-^HUÀ^CðAæ^C0pM-^GÀSleeperThreadAborting^G{{username::
RAB2002}}{{scriptname::scs_get_pending_by_loc}}01ðAæ^Bñ^F×Ø01Ó^P0vÕ 0pM-^H`ðQM-^EÐÐ^_» ^CðR
         901Ë(0pM-^H`ðR  ÓM-^E¬ð0pM-^H°0pM-^Hpñ^G(T0pM-^I<^AðQM-^EÐðQM-^IÄ0B^P0pM-^I<010pM-^H ñ^FÙM-^HÓM-^E
¬ð0pM-^Hàñ^G(TÐ^_ãÄ^A^V01Ó^T^A0pM-^Hà^P M-^HÔ0pM-^I,0pM-^Hà^T^M^A^L^G^C9[RAB2002] - [root]°ðR
 galaxy/1196224/5912ðQM-^ISRV0051_09_0//265088 ðB*¨0X-00pWM-^@ðQM-^IM-^HÐ^_ã^P0pW00pW ðAæ<182071
208/274991/273036ðB*¨01Ó@0pWÀ^D^EÓM-^HUÀ^CðAæ^C0pWÀSleeperThreadAborting^G{{username::RAB
2002}}{{scriptname::scs_get_pending_by_loc}}0RM-^Q¸ðAæ^Bñ^F×Ø0f¥`0M-^Pa@0pX`ðQM-^EÐÐ^_» ^CðR
 90X-80pX`ðR     ÓM-^E¬ð0pX°0pXpñ^G(T0pY<^AðQM-^EÐðQM-^IÄ0B^P0pY<01ÓH0pX ñ^FÙM-^HÓM-^E¬ð0pXàñ^G(TÐ
^_ãÄ^A^V0f¥d^A0pXà^P    M-^HÔ0pY,0pXà^T^M^A^L^G3^P[CAW9041] - [root]°ðR  galaxy/635000/5
912ðQM-^ISRV0051_02_0//100040 ðB*¨00ú00pwM-^@ðQM-^IM-^HÐ^_ã^P0pw00pw ðAæ8182075098/250005/100040
# 2  
Old 02-12-2014
Ever considered using stringscommand?
# 3  
Old 02-12-2014
Can you please give more hints?
# 4  
Old 02-12-2014
strings will try to print whatever it believes is printable strings... in an true binary... If this does not work then your file is not binary or contains no true binary, but is more "data", in which case its a different story...
# 5  
Old 02-12-2014
Do you have a sample script I can try, please?

---------- Post updated at 09:26 PM ---------- Previous update was at 12:21 PM ----------

There's a pattern of the segment I need. Is there a way to use pattern to extract them out?
# 6  
Old 02-12-2014
What exactly are you trying to extract?

Here is a sample program which you can start working with:
Code:
awk '
        /Sleep/ {
                match ( $0, /Sleep.*/ )
                v = sprintf ( "%s", substr ( $0, RSTART, RLENGTH ) )
                getline;
                v = v $0
                sub ( /\}[^}]*$/, "}", v )
                sub ( /g[^{]*/, "g", v )
                print v
        }
' file

# 7  
Old 02-13-2014
[QUOTE=Yoda;302888148]What exactly are you trying to extract?

I need to extract this i.e.
HTML Code:
SleeperThreadAborting {{username::RAB2002}} {{scriptname::scs_get_pending_by_loc}}
All of them begin with SleeperThreadAborting and end with }}.



If I can extract from SleeperThreadAborting ..... to }} , that will be perfect.
Please let me know if possible. Appreciate it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trimming ends

My files look like this I need to remove the sequence GGGAAA and anything before that I also need to remove the sequence AGCCCTA and anything after that So I will end up with something like this The left side is done but I cannot get the right side correctly. I would like to use... (3 Replies)
Discussion started by: Xterra
3 Replies

2. Shell Programming and Scripting

Trimming in between the words

Hi i have a log file P12345_15728710:DEBUG:Begin P12345_15728710:DEBUG:Being P12345_15729310:DEBUG:GetAgen P12345_15726510:DEBUG:end i want to trim this file and i want like this 15728710 15728710 15729310 15726510 i tried sed ..but not working.. sed "s/.*P12345__ \(.*\)... (4 Replies)
Discussion started by: navsan420
4 Replies

3. Shell Programming and Scripting

Trimming a string

Hi I need to trim white spaces from strings in a file. Input file is like this: 1_rrc_CatalogGroups.csv = 607 1_rrc_Sales_TopCatalogGroups.csv = 4 1_rrc_Sales_CatalogEntries_CatalogGroup_Rel.csv = 7 Need to trim space before and after = symbol. This is my script: #!/usr/bin/ksh ... (2 Replies)
Discussion started by: sukhdip
2 Replies

4. Programming

Data segment or Text segment

Hi, Whether the following piece of code is placed in the read-only memory of code (text) segment or data segment? char *a = "Hello"; I am getting two different answers while searching in google :( that's why the confusion is (7 Replies)
Discussion started by: royalibrahim
7 Replies

5. Shell Programming and Scripting

trimming sequences

My file looks like this: But I would like to 'trim' all sequences to the same lenght 32 characters, keeping intact all the identifier (>GHXCZCC01AJ8CJ) Would it be possible to use awk to perform this task? (2 Replies)
Discussion started by: Xterra
2 Replies

6. Shell Programming and Scripting

Trimming output

I'm trying to parse an output log and I've managed to reduce the output to the lines I need. But I'm having trouble pulling out only the info I'm interested in. The output is 40+ lines and here is a sample Installing AppFresh 0.8.5.pkg from ./InstallerFiles/CustomPKG/26 (26) Installing... (2 Replies)
Discussion started by: kaltekar
2 Replies

7. UNIX for Advanced & Expert Users

Trimming the spaces

Hi, How can I remove the unwanted spaces in the line. 123456 789 ABC DEF. - I wanna remove the sapces in this line, I need the output 123456789ABCDEF. Pls help me...... (3 Replies)
Discussion started by: sharif
3 Replies

8. UNIX for Advanced & Expert Users

trimming zeros

Hi, I want to trim +with leading zero's with amount fields.I know using awk for trimming leading zeros with +,but I want get the entire row itself. cat file_name |awk -F " " '{printf "%14.4f%f\n",$4}' ex: 10 xyz bc +00000234.4500 20 yzx foxic +002456.000 Expexted 10 xyz bc... (3 Replies)
Discussion started by: mohan705
3 Replies

9. Shell Programming and Scripting

Trimming a string

Hi, I am trying to find a script command that will let me trim leading and trailing space from a string. I have coded a SQL Select and sending the output to a file. Later I am parsing the file and reading each field. The problem is that each field uses the same size as the DB2 type it was defined... (2 Replies)
Discussion started by: fastgoon
2 Replies

10. UNIX for Dummies Questions & Answers

trimming a file...

Hi everyone I have this script that appends a line to a file to log the running status of an application. I need to write another script to run as a scheduled job in cron to trim the first x number of lines of this file. Could someone give me an idea how to do this? Regards (1 Reply)
Discussion started by: alwayslearningunix
1 Replies
Login or Register to Ask a Question