Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

match lines with ";" caracter 1

Status
Not open for further replies.

paketecuento

Technical User
Nov 28, 2009
4
ES
Hi,

I was trying to build some kind of filter for files containing commented lines (those starting wiht ";"). The problem arises when some of these lines are indented. For example:

-------------------------------------
foo.conf

;hello
variable=12 ;some comment
;comment indented
[section]
;var=5 ;another comment
type=friend
--------------------------------------

So I expect the final result as:

variable=12 ;some comment
[section]
type=friend

any suggestion??

regards, paco
 
You may try something like this:
Code:
awk '!/^[ \t]*;/' foo.conf

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
yes, it works!!!

Only now, it rest to hide/delete all the blank lines in the output.. I mean:

var1=1


var2=2

var3=3

should be

var1=1
var2=2
var3=3

thanks
 
it looks like this do the trick for me

Code:
awk '!/^[ \t]*;/' foo.conf | awk '$0!~/^$/ {print $0}'
 
What about this ?
Code:
awk '!/^[ \t]*;/ && NF' foo.conf

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top