grep from file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

grep from file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-10-2008
jaydeep_sadaria jaydeep_sadaria is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 19 July 2014, 1:26 PM EDT
Posts: 58
Thanks: 4
Thanked 0 Times in 0 Posts
grep from file

hi all

I am using below mention file as input file. Now i want to grep only contain between BSCANGR( op mention below). line containg between BSCANGR may be vary its not fix.

Kindly suggest me.


*** BSCANGR
RXOTRX-280-1 INTERNAL
RXOTRX-48-2 MODE
RXOTRX-48-3 MODE
RXOTRX-194-11 MODE
RXOTRX-194-10 MODE
RXOTRX-147-0 INTERNAL
*** BSCANGR
*** BSCSLP2
RXOTRX-20-1 INTERNAL
RXOTRX-4-2 MODE
RXOTRX-4-3 MODE
RXOTRX-14-11 MODE
RXOTRX-14-10 MODE
RXOTRX-17-0 INTERNAL
*** BSCSLP2


op need to like this:

*** BSCANGR
RXOTRX-280-1
RXOTRX-48-2
RXOTRX-48-3
RXOTRX-194-11
RXOTRX-194-10
RXOTRX-147-0
*** BSCANGR


also i am thank full if some one suggest for below mention op.from same file.

@ CONNECT('BSCANGR')
RXCDP:RXOTRX-280-1;
RXCDP:RXOTRX-48-2
RXCDP:RXOTRX-48-3
RXCDP:RXOTRX-194-11
RXCDP:RXOTRX-147-0
@ DISCONNECT
Sponsored Links
    #2  
Old 04-10-2008
in2nix4life's Avatar
in2nix4life in2nix4life is online now
Registered User
 
Join Date: Oct 2007
Last Activity: 21 August 2014, 3:50 PM EDT
Location: East Coast
Posts: 610
Thanks: 1
Thanked 175 Times in 161 Posts
You can use 'sed' to extract the section of the file that you want like so:

sed -n '/BSCANGR/,/BSCANGR/p' file.txt

Hope this helps.
Sponsored Links
    #3  
Old 04-10-2008
jaydeep_sadaria jaydeep_sadaria is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 19 July 2014, 1:26 PM EDT
Posts: 58
Thanks: 4
Thanked 0 Times in 0 Posts
grep

plz also suggest for below mention op if possible.

@ CONNECT('BSCANGR')
RXCDP:RXOTRX-280-1;
RXCDP:RXOTRX-48-2
RXCDP:RXOTRX-48-3
RXCDP:RXOTRX-194-11
RXCDP:RXOTRX-147-0
@ DISCONNECT
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Pipe binary file matches grep results to file chipperuga UNIX for Dummies Questions & Answers 0 01-23-2012 01:25 PM
script to grep a pattern from file compare contents with another file and replace namitai Shell Programming and Scripting 2 08-30-2011 01:31 PM
Grep a pattern given in one file at other file and display its corresponding contents as output. abinash Shell Programming and Scripting 7 02-23-2011 01:51 AM
Grep pattern from different file and display if it exists in the required file abinash Shell Programming and Scripting 3 12-08-2010 08:20 AM
grep for certain files using a file as input to grep and then move anita07 Shell Programming and Scripting 2 12-10-2009 03:59 AM



All times are GMT -4. The time now is 04:00 PM.