Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


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 !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-11-2012
saj saj is offline
Registered User
 
Join Date: Apr 2011
Posts: 29
Thanks: 4
Thanked 0 Times in 0 Posts
Pattern search

Hi All ,

Please let me know how to get the below scenario done .

Below is the file pattern which I have ...


Code:
      BEGIN DSSUBRECORD
         Name "a"
         Prompt "b"
         Default "c"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
      END DSSUBRECORD
      BEGIN DSSUBRECORD
         Name "d"
         Prompt "e"
         Default "f"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
      END DSSUBRECORD
      BEGIN DSSUBRECORD
         Name "g"
         Prompt "h"
         Default "i"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
      END DSSUBRECORD
      BEGIN DSSUBRECORD
         Name "j"
         Prompt "k"
         Default "l"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
      END DSSUBRECORD
      BEGIN DSSUBRECORD
         Name "m"
         Prompt "n"
         Default "p"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
      END DSSUBRECORD


I need to print the records starting from Name to ParamScale .Please note there are spaces in front of these lines .

Expected output:

Code:
         Name "a"
         Prompt "b"
         Default "c"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
         Name "d"
         Prompt "e"
         Default "f"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
         Name "g"
         Prompt "h"
         Default "i"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
         Name "j"
         Prompt "k"
         Default "l"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"
         Name "m"
         Prompt "n"
         Default "p"
         ParamType "0"
         ParamLength "0"
         ParamScale "0"

Please help .....

Last edited by Scrutinizer; 06-11-2012 at 01:40 PM.. Reason: code tags
Sponsored Links
    #2  
Old 06-11-2012
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,357
Thanks: 144
Thanked 1,756 Times in 1,593 Posts
Try:
Code:
grep -v DSSUBRECORD file

Sponsored Links
    #3  
Old 06-11-2012
gary_w's Avatar
Registered User
 
Join Date: Oct 2010
Posts: 446
Thanks: 31
Thanked 96 Times in 88 Posts
Conversely:

Code:
 grep '"' file

:-)
    #4  
Old 06-11-2012
saj saj is offline
Registered User
 
Join Date: Apr 2011
Posts: 29
Thanks: 4
Thanked 0 Times in 0 Posts
There are other contents also in the file . I had provided a part of the file ...
Sponsored Links
    #5  
Old 06-12-2012
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,357
Thanks: 144
Thanked 1,756 Times in 1,593 Posts
Try:

Code:
awk '$1=="Name",$1=="ParamScale"' infile

Sponsored Links
    #6  
Old 06-12-2012
saj saj is offline
Registered User
 
Join Date: Apr 2011
Posts: 29
Thanks: 4
Thanked 0 Times in 0 Posts
The above is not the full content of the file .. its a portion of the file ..
Sponsored Links
    #7  
Old 06-12-2012
Scrutinizer's Avatar
Moderator
 
Join Date: Nov 2008
Location: Amsterdam
Posts: 7,357
Thanks: 144
Thanked 1,756 Times in 1,593 Posts
Did you try #5 ? What did you get and what did you expect?
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
Need one liner to search pattern and print everything expect 6 lines from where pattern match made chidori Shell Programming and Scripting 8 03-15-2012 11:46 AM
Print a pattern between the xml tags based on a search pattern oky Shell Programming and Scripting 13 03-21-2011 01:03 PM
search a pattern and if pattern found insert new pattern at the begining pitagi Shell Programming and Scripting 7 02-12-2009 09:27 PM
modify a particular pattern starting from second line of the search pattern imas UNIX for Dummies Questions & Answers 2 10-12-2008 11:30 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 02:41 PM



All times are GMT -4. The time now is 05:54 AM.