extract a portion of log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extract a portion of log file
# 1  
Old 07-20-2006
Question extract a portion of log file

hello,
I want to grep the log file according to time and get the portion of log from one particular time to other.
I can grep for individual lines by time but how should I print lines continuously from given start time till end till given end time.

Appreciate your ideas,
Thanks
chandra
# 2  
Old 07-21-2006
What does the time format look like ?

You might want to look at sed. Something on the lines of

Code:
sed -e "/start pattern/,/end pattern/p" file

# 3  
Old 08-02-2006
Hello vino,
when I am using
sed -e "/start pattern/,/end pattern/p" file > tmpfile
tmpfile is containing duplicate lines from start pattern to end pattern along with the whole 'file'. I am not able to output only those lines ???
I was getting what I wanted when I do diff between two files but now I need it in a file.
Need assistance...Thanks
# 4  
Old 08-02-2006
try sed -n not sed -e
# 5  
Old 08-02-2006
thankyou, that helped.

If I have to put these lines from start pattern to end pattern into another file at the same place, I am not able to do so.
I tried to use sed -s again to try if it adds to the target file. but its adding at the end and also duplicating the lines.

sed -n 's/\"/echo config_start/,/echo \"end_install\"/p"//' config1.log>tmpfile

sed -n 's/\"/echo config_start/,/echo \"end_install\"/p"//' tmpfile config2.log
when I do this, it's adding each line in tmpfile twice and also at the end of config2.log

When looked into sed, i saw sed -f functionality but not able to get the syntax.

I need help in this one aswell.
Regards
chandra
# 6  
Old 08-02-2006
I tried several combinations with awk, but the only piece missing is that the lines sitting at the right place in the file.
As sed -n picked the lines from a start pattern, I want to insert them exactly like that. Smilie
Any suggestions ...
# 7  
Old 08-03-2006
We really appreciate help on this...
Basically I have file which has:
...
...
echo config_start
text1
text2
...
few lines of text
echo end_install
...

Another file has
....
...
echo config_start
echo end_install
....
I need to copy from file1 to file2.
With the sed command below, I was able to get the text from file1. But couldn't put it in file2.

Please need help on this..guys...appreciate your ideas..
I browsed in this forum and I got this lead...can/how do I use it ??

$ cat fileToEdit | sed -e "$lineToEnterNewText"' s/^\(.*\)$/\1\
'"$newText"'/' > fileToEdit

Thanks
Chandra
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Extract a portion of string from each line in Linux

Hi I have to extract the destination path information from each record the file is of variable length so I will not be able to use the print command.The search should start on variable "destinationPath" and it should end at immediate "," also the first field has to be printed Input File:... (7 Replies)
Discussion started by: rkakitapalli
7 Replies

2. Shell Programming and Scripting

Extract portion of data

Hi Gurus, I need some help in extracting some of these information and massage it into the desired output as shown below. I need to extract the last row with the header in below sample which is usually the most recent date, for example: 2012-06-01 142356 mb 519 -219406 mb 1 ... (9 Replies)
Discussion started by: superHonda123
9 Replies

3. Shell Programming and Scripting

How to extract portion of a string?

Hi Gurus, Would like to seek some help on how to extract a portion of string from log's output as shown below. Sample of raw data: piece handle=/test123/disk_dump/test123/df0_cntrl_PCPFCI20120404_68498 tag=TAG20120404T180035 comment=NONE piece... (13 Replies)
Discussion started by: superHonda123
13 Replies

4. Shell Programming and Scripting

Extract portion of log info based on specific word

Hi Gurus, I'm using HP-UX B.11.23 operating system. I've been trying to extract a specific wording for example: "A tool used by tp produced warnings" from my below log data, but could not find a way to solve it. My intention is, if the log contain the word: "A tool used by tp produced... (9 Replies)
Discussion started by: superHonda123
9 Replies

5. Shell Programming and Scripting

How to extract a text portion from a file

Can some one help me with shell script to extract a text block between two known strings. The given input file is as below: Name: abs Some tesxt.... Some tesxt.... Some tesxt.... end of text Name: xyz Some tesxt.... Some tesxt.... Some tesxt.... end of text Name: efg Some... (5 Replies)
Discussion started by: ejazs0
5 Replies

6. Shell Programming and Scripting

extract string portion from filename using sed

Hi All, I posted something similar before but I now have a another problem. I have filenames as below TOP_TABIN240_20090323.200903231830 TOP_TABIN235_1_20090323.200903231830 i need to extract the dates as in bold. Using bash v 3.xx Im trying to using the print sed command but... (11 Replies)
Discussion started by: santam
11 Replies

7. Shell Programming and Scripting

extract string portion using sed

Hi All I have 3 files as listed below and highlighted in bold the portions of the filenames I need to extract: TOS_TABIN218_20090323.200903231830 TOS_TABIN219_1_20090323.200903231830 TOS_TABIN219_2_20090323.200903231830 I tried source_tabin_name=`echo $fname | sed 's/_.*//'` but I... (6 Replies)
Discussion started by: santam
6 Replies

8. UNIX for Advanced & Expert Users

Grep a portion of the log file

I want to grep a portion of the log file. grepping a particular pattern and including 10 lines before that and after that occurence. grep -n "SomeString Pattern" filename 10 lines before this occurence and 10 lines after that. Please help. Need the simple script not in awk or sed. (9 Replies)
Discussion started by: sainipardeep
9 Replies

9. UNIX for Dummies Questions & Answers

How to extract a portion of text from a log file

I am using Unix on Mac OS X 10.5.6. I am trying to extract the last entry of a log (text) file. As seen below, each log entry looks like the following (date and time change with each log entry): I want the script to extract everything quoted above, including the "===" dividers. ... (2 Replies)
Discussion started by: atilano
2 Replies

10. Shell Programming and Scripting

extract date portion from file

Hi, I have a file where there is a date field (single line variable length file) how to extract just the date portion from it the position of date field may vary anywhere in the line but will always have the format mm-dd-yyyy for eg . xxxxxxxxxxxxxxx09-10-2006xxxxxxxxxxxxxxxxxxxx (5 Replies)
Discussion started by: misenkiser
5 Replies
Login or Register to Ask a Question