The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
tail | grep lagging badly WasabiVengeance Shell Programming and Scripting 3 04-22-2008 07:53 PM
grep problem with the ^ symbol, help needed please. Gvsumrb UNIX for Dummies Questions & Answers 2 03-31-2008 11:04 AM
tail, grep and cut sylaan Shell Programming and Scripting 7 03-04-2008 02:41 AM
Help Needed in Grep Command ranga27 UNIX for Advanced & Expert Users 7 09-11-2007 10:20 AM
Constantly updating log files (tail -f? grep? awk?) nortonloaf UNIX for Dummies Questions & Answers 0 12-03-2006 11:20 PM

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 05-17-2007
Felix2511 Felix2511 is offline
Registered User
  
 

Join Date: May 2007
Location: Madrid,Spain
Posts: 20
Help with tail /grep needed

Hello:

I'm a very newbee at UNIX/AIX.
What i want to do is to tail a file from the bottom until a certain string is found and write all the lines after the found string to another file.
I've tried out a lot of combination with tail and grep but doesn't find the good one.

Could someone help me or give me a hint with this issue?

Many thanks in advance,
Felix
  #2 (permalink)  
Old 05-17-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Felix,
Could you please give us a sample of input and output?
Thanks
  #3 (permalink)  
Old 05-17-2007
Felix2511 Felix2511 is offline
Registered User
  
 

Join Date: May 2007
Location: Madrid,Spain
Posts: 20
INPUT lOG:-> this is the file i want to serach -> string to searchatabase Connection Information

Database Connection Information

Database server =
SQL authorization ID =
Local database alias =

Number of rows read = 18724
Number of rows skipped = 0
Number of rows loaded = 18724
Number of rows rejected = 0
Number of rows deleted = 0
Number of rows committed = 18724
DB20000I The RUNSTATS command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
B20000I The RUNSTATS command completed successfully.



Database Connection Information

Database server =
SQL authorization ID =
Local database alias =
Number of rows read = 18724
Number of rows skipped = 0
Number of rows loaded = 18724
Number of rows rejected = 0
Number of rows deleted = 0
Number of rows committed = 18724
DB20000I The RUNSTATS command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The RUNSTATS command completed successfully.
---------- --------------- -------------- ------------- -------------
The Output file i want to have is only the first part of it beginning from the buttom:
Database Connection Information

Database server =
SQL authorization ID =
Local database alias =
Number of rows read = 18724
Number of rows skipped = 0
Number of rows loaded = 18724
Number of rows rejected = 0
Number of rows deleted = 0
Number of rows committed = 18724
DB20000I The RUNSTATS command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
DB20000I The RUNSTATS command completed successfully.

Thank you.
  #4 (permalink)  
Old 05-17-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Felix,
See if this works for you:
Code:
mBaseStr='Database Connection Information'
mLastOccur=`egrep -n "$mBaseStr" input_file | tail -1`
mFromLine=`echo $mLastOccur | cut -d':' -f1`
tail +$mFromLine input_file
  #5 (permalink)  
Old 05-17-2007
Felix2511 Felix2511 is offline
Registered User
  
 

Join Date: May 2007
Location: Madrid,Spain
Posts: 20
It works fine.

Thank you very much indeed.
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 11:57 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