The UNIX and Linux Forums  

Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
select a portion of a file into a CSV anju Shell Programming and Scripting 8 02-28-2008 01:50 AM
Delete Portion of a file sameersbn High Level Programming 2 01-20-2007 12:16 AM
extract date portion from file misenkiser Shell Programming and Scripting 5 10-06-2006 05:37 AM
remove portion of file methos Shell Programming and Scripting 13 08-16-2002 09:26 AM
How to extract a portion of a string from the whole string ds_sastry UNIX for Dummies Questions & Answers 2 09-29-2001 10:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-20-2006
chandra004 chandra004 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 19
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 (permalink)  
Old 07-21-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
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 (permalink)  
Old 08-02-2006
chandra004 chandra004 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 19
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 (permalink)  
Old 08-02-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,753
try sed -n not sed -e
  #5 (permalink)  
Old 08-02-2006
chandra004 chandra004 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 19
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 (permalink)  
Old 08-02-2006
chiru_h chiru_h is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 72
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.
Any suggestions ...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0