String searching and output to a file in a formatted text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String searching and output to a file in a formatted text
Prev   Next
# 1  
Old 07-20-2010
String searching and output to a file in a formatted text

Hi,
I'm very new to UNIX scripting and find quite difficult to understand simple UNIX syntax. Really appreciat if somebody could help me to give simple codes for my below problems:-

1) I need to search for a string "TTOH 8031950001" in a files which filename will be "*host*'. For example, the string I searceh found in below line:-

<Jun 30, 2010 5:06:59 PM GMT+08:00> <DEBUG> <MessageFormatter> {F5380112-1890-3589-1A9E-7F135D382013} sending [ CAMSTTOH TTOH 8031950001 53020001706590000 000001 6 009 21403500125671 ENG AUN CHAN Y 00257600006 ENG AUN CHAN 3445456567 ANANDA KRISHNAN N 100002322 20100630 N N 000000000200000 000000000000200 000000000200200 10125 CAMS21301000007960 10063002024620002 N 000000000000000 ]
(Please consider above is in a single line)

2) The line is too long. I just need Item in the position 2 to 14, Items in {}, sending until end of line.
Jun 30, 2010 F5380112-1890-3589-1A9E-7F135D382013 sending [ CAMSTTOH TTOH 8031950001 53020001706590000 000001 6 009 21403500125671 ENG AUN CHAN Y 00257600006 ENG AUN CHAN 3445456567 ANANDA KRISHNAN N 100002322 20100630 N N 000000000200000 000000000000200 000000000200200 10125 CAMS21301000007960 10063002024620002 N 000000000000000 ]

Then, it will be in a formatted text file.

Anyone can help to come out with a script?
Thanks in advance..Smilie

Note:-
1)I attached sample of files to be search - batch-host.log.6
2)I attached sample expected output file.

Compressed in a sample.zip file
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

2. HP-UX

Formatted TOP command output in file

Hi All, I want generate HP-UX overall system performance report. I tried executing top command and write that out put to file. but am not able to view the report in proper format. I can see report like below in file but i can see properly in terminal. Please suggest how can i get... (2 Replies)
Discussion started by: lravip123
2 Replies

3. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

4. Shell Programming and Scripting

Searching for a particular string and modifying text within block of data

Hi Forum. Is there a quick way to do the following search/replace within a block of data? I tried to google the solution but didn't really know what to look for. I have the following text file (I want to search for a particular string "s_m_f_acct_txn_daily_a1" and replace the... (5 Replies)
Discussion started by: pchang
5 Replies

5. Shell Programming and Scripting

searching a text string for n'th :

hello, i'm a novice on bsh scripting so thanks for any help here basically i have a shell var $x that looks like this > echo $x nabc1234:!:73394:17155:Gary Mason:/home/garym:/bin/ksh and i'm trying to keep the first 8 characters and the text from the 4th : to the 5th : i've been trying... (9 Replies)
Discussion started by: sasglm
9 Replies

6. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

7. Shell Programming and Scripting

PERL: Searching for a string in a text file problem

Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines. for example the text output is: United Chanmpions Ronaldo Liverpool Losers Torres and my script code is print("DEBUG - checking file message"); while... (15 Replies)
Discussion started by: meevagh
15 Replies

8. Shell Programming and Scripting

Searching and extracting text from output

I have the following output which I need to obtain the values for "Next Seq is xxx" and "Last Seq is xxx" and "Pending count is xxx". You will notice that the number of words prior to that value can be variable hence the reason for asking this question. LINECMD> Line /xxx///ABC9_SND is UP.... (3 Replies)
Discussion started by: sjday
3 Replies

9. Shell Programming and Scripting

Convert DATE string to a formatted text

Hi guys, i need your help. I need to convert a date like this one 20071003071023 , to a formated date like 20071003 07:10:23 . Could this be possible ? Regards, Osramos (6 Replies)
Discussion started by: osramos
6 Replies

10. UNIX for Dummies Questions & Answers

Hi! Searching for a text string in UNIX

Hi! I'm new here and glad to meet everyone! I've been wrestling with a problem lately however! How do I recursively (recursive means to keep going through the subdirectories until no more are there) search a bunch of textfiles in a long directory structure for a specific string.. but only... (1 Reply)
Discussion started by: skwadim
1 Replies
Login or Register to Ask a Question