Removing lines having #

I have a script which goes to different directories and gives the values of all the input parameters, Something as follows

  cd /opt
grep script-filter = yes *.conf
grep user-and-group-in-same-suffix = yes *.conf
grep worker-threads = 300 *.conf
grep failover-auth = *.conf
grep failover-password = *.conf
netstat -rn
cd /opt/Pddirector/etc
grep sync = *.conf 

The result is a output which is as follows

[JB007@mac901 ~]$ ./VerifyConf.sh 
grep: =: No such file or directory
grep: yes: No such file or directory
# are added to this list then the option [script-filtering]script-filter
[script-filtering]
script-filter = yes
# When script-filter is set to yes, enabling this flag will rewrite
# are added to this list then the option [script-filtering]script-filter
[script-filtering]
script-filter = yes
# When script-filter is set to yes, enabling this flag will rewrite
grep: =: No such file or directory
grep: yes: No such file or directory
# user-and-group-in-same-suffix
user-and-group-in-same-suffix = yes
# user-and-group-in-same-suffix
user-and-group-in-same-suffix = yes
grep: =: No such file or directory

Im trying to just get the output without the lines having the "#"

Please help,

Thanks in advance.
JB:)

You could try adding another grep to filter out the lines beginning with '#':

grep script-filter = yes *.conf | grep -v '#'

Hope this helps.

To remove comment lines starting with a hash character:

cat filename | sed -e "/^#/d"

kinda UUOC-ish

Please post cat-less version.

put filename at the end of the sed command

Thx. Prefer left-to-right top-to-bottom in scripts.
Your method is faster in script execution but slower for students to follow.

huh ?

I alredy have an infraction from Room 101 on this topic. Topic closed.

I am not sure how you are okay with all those error messages strewn all around. If you want to search for the exact string "script-filter = yes" in *.conf then you may want to enclose it within quotes:

$
$ cat file1.conf
blah blah blah
# are added to this list then the option [script-filtering]script-filter
blah blah blah
$
$ cat file2.conf
[script-filtering]
blah blah blah
$
$ cat file3.conf
blah blah blah
script-filter = yes
#script-filter = yes
blah blah blah blah script-filter = yes
# blah blah blah blah script-filter = yes
blah blah blah
$
$ grep "script-filter = yes" *.conf
file3.conf:script-filter = yes
file3.conf:#script-filter = yes
file3.conf:blah blah blah blah script-filter = yes
file3.conf:# blah blah blah blah script-filter = yes
$
$

If you want to find out lines that have "script-filter = yes" anywhere in the line, as long as the line does not start with "#", then you could do something like:

$
$ grep "^[^#]*script-filter = yes" *.conf
file3.conf:script-filter = yes
file3.conf:blah blah blah blah script-filter = yes
$

HTH,
tyler_durden

____________________________________________________
"Only after disaster can we be resurrected."