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

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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.Unix or Linux Image
Sponsored Links
    #2  
Old Unix and Linux 01-20-2013
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 4 March 2015, 3:28 AM EST
Location: Zürich
Posts: 8,525
Thanks: 336
Thanked 1,061 Times in 924 Posts
In what language, and why have you posted in the Red Hat forum?
Sponsored Links
    #3  
Old Unix and Linux 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. Unix or Linux Image

Last edited by Scott; 01-20-2013 at 07:45 AM.. Reason: Code tags, please...
    #4  
Old Unix and Linux 01-20-2013
elixir_sinari's Unix or Linux Image
elixir_sinari elixir_sinari is offline Forum Advisor  
Registered User
 
Join Date: Mar 2012
Last Activity: 9 October 2014, 4:50 PM 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 Unix and Linux 01-20-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 24 February 2015, 2:15 PM EST
Location: Galactic Empire
Posts: 3,401
Thanks: 240
Thanked 1,215 Times in 1,141 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 Unix and Linux 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 Unix or Linux Image
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 05:36 AM
Filter a .kml file (xml) with data set from text file pcoj33 Shell Programming and Scripting 5 10-19-2011 02:28 PM
To filter a log file dattatraya Shell Programming and Scripting 1 09-08-2008 11:51 PM
File filter Dastard Shell Programming and Scripting 3 09-06-2007 02:50 PM
filter out certain column from a file CamTu Shell Programming and Scripting 4 04-04-2005 07:24 PM



All times are GMT -4. The time now is 07:12 AM.