The UNIX and Linux Forums  

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
grep string & a few lines after ashterix Shell Programming and Scripting 7 12-07-2008 09:20 AM
Grep string but also it will show the next 5 lines thepurple Shell Programming and Scripting 10 10-07-2008 08:03 AM
Grep for lines between words in a file using TCL.. ramkriz Shell Programming and Scripting 3 08-26-2008 08:55 AM
find string, then get the next 3 lines in a file lyoncc Shell Programming and Scripting 8 11-07-2007 06:30 AM
grep string & next n lines ashterix Shell Programming and Scripting 8 11-21-2005 11:38 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-06-2008
suman82 suman82 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 5
To grep 10 lines after a string in a txt file.

Hi All,
I am trying to pull 10 lines from a file after some particular string. Please help me in doing so.

Example;
Let us take a file.

Test_file_log.txt

Test_file_log contents:

request_id = 11191
Test data related to 11122
test date
trst data
test data

request_id = 11123
test data related to 11123
test_data
test_data

request_id = 11234
test data related to 11234
test_data
test_data

Our requirment: Need to get the data for the given request_id and send it over to other file.

here request_id is dynamic. We pass the request_id value.

Let us suppose we need the data for
v_request_id = 11123

grep "request_id = v_request_id" and also 10 lines after this string. Then send this information to other file.

>request_id_data.txt

Finally Request_id_data.txt should have the log of only the given request_id

Please help me in coding the above. I am searching in all forums but cannot able to get the info. We are trying to do this from past 2 months.

Thanks in advance

Regards,
Suman.
 

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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:04 AM.


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