Help me to filter a file | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

Help me to filter a file

UNIX for Dummies Questions & Answers


Tags
red hat, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-20-2013
Pradipta Kumar Pradipta Kumar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 13 February 2014, 7:35 AM EST
Location: Bangalore
Posts: 8
Thanks: 4
Thanked 1 Time in 1 Post
RedHat Help me to filter a file

I want to view a file ignoring mutilple comment line (/*....*/). Please help me on this.

Advance thanks.
Sponsored Links
    #2  
Old 01-20-2013
Scott's Avatar
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 17 September 2014, 6:50 AM EDT
Location: Zürich
Posts: 8,475
Thanks: 331
Thanked 1,046 Times in 913 Posts
In what language, and why have you posted in the Red Hat forum?
Sponsored Links
    #3  
Old 01-20-2013
Pradipta Kumar Pradipta Kumar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 13 February 2014, 7:35 AM EST
Location: Bangalore
Posts: 8
Thanks: 4
Thanked 1 Time in 1 Post
Actually I want to see configuration file in Linux and I want to view the content which is not commented.
I have tried below command line, but its omitting only the /* */ character not the block which is occupy by /*..*/
Ex:

Code:
cat named.conf | egrep -v "^[[:blank:]]*($|#|//|/\*| \*|\*/)"

Please help me on this.. Thank you.

Last edited by Scott; 01-20-2013 at 06:45 AM.. Reason: Code tags, please...
    #4  
Old 01-20-2013
elixir_sinari's Avatar
elixir_sinari elixir_sinari is offline Forum Advisor  
Registered User
 
Join Date: Mar 2012
Last Activity: 9 September 2014, 8:08 AM EDT
Location: India
Posts: 1,412
Thanks: 101
Thanked 496 Times in 473 Posts
Try:

Code:
perl -p0e 's:/\*.*?\*/::sg' named.conf

The Following User Says Thank You to elixir_sinari For This Useful Post:
Pradipta Kumar (01-21-2013)
Sponsored Links
    #5  
Old 01-20-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 16 September 2014, 5:12 PM EDT
Location: Galactic Empire
Posts: 3,380
Thanks: 234
Thanked 1,204 Times in 1,131 Posts

Code:
awk 'BEGIN {f=0;}{for(i=1;i<=NF;i++){ if($i=="/*") f=1; if($i=="*/") f=0;
 if(f==0&&!($i=="/*"||$i=="*/")) {
 $i=(i==NF)?$i RS:$i" "; printf "%s", $i ;
 }}
}' named.conf

The Following User Says Thank You to Yoda For This Useful Post:
Pradipta Kumar (01-21-2013)
Sponsored Links
    #6  
Old 01-21-2013
Pradipta Kumar Pradipta Kumar is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 13 February 2014, 7:35 AM EST
Location: Bangalore
Posts: 8
Thanks: 4
Thanked 1 Time in 1 Post
RedHat

Thank you All,,

Both command are working...

Thank you very much
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
How to filter out data file...? nex_asp Shell Programming and Scripting 5 12-09-2012 04:36 AM
Filter a .kml file (xml) with data set from text file pcoj33 Shell Programming and Scripting 5 10-19-2011 01:28 PM
To filter a log file dattatraya Shell Programming and Scripting 1 09-08-2008 10:51 PM
File filter Dastard Shell Programming and Scripting 3 09-06-2007 01:50 PM
filter out certain column from a file CamTu Shell Programming and Scripting 4 04-04-2005 06:24 PM



All times are GMT -4. The time now is 09:30 AM.