The problem is that your expression is matching Listen followed by any number of spaces then 443. Your definition is explicit in being for 'any number of spaces' with the * sequence.
Do you really mean "Match records that start with Listen and end with :443 #" ? That would be grep "^Listen.*:443 #$" or you could be more explicit and say that it would have to match an IP address structure with "^Listen.*([0-9]{1,3}\.){3}[0-9]{1,3}:443 #$"
To explain a little more:-
So to expand more on ([0-9]{1,3}\.){3} the braces {3} mean three of the previous thing. In this case the thing is ([0-9]{1,3}\.) which is between 1 & 3 digits followed by an explicit dot/full stop. You have to use \. because the dot is special as you have in the .* which means any number of any character.
If the line might not start with Listen then you might just want to exclude a leading #, so you end up with the more complicated "^[^#]Listen.*([0-9]{1,3}\.){3}[0-9]{1,3}:443 #$" which is "Do not start with a hash. The [^#] means "Not this/these character(s)" which might be a bit confusing given it follows a ^ marking the start of the line. Of course if this might not be the first character, you might want to drop the first ^ anchoring it to the start of the line.
I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days...
The structure of the paths are like this:
/home/domains/www.domain2.com/tgp/
/home/domains/www.domain3.com/tgp/... (1 Reply)
How can
grep G.*schema
give me the result: ${Gacntg_dt}""'"'
doesn't G.*schema say give me an unlimited number of characters between G and schema?
:confused: (3 Replies)
Hi All,
Below is my code,what I am trying to do is redirecting output of ftp to a log file & then greping the errors but here I am unable to grep "Permission denied" error only & also the corresponding log file is also not getting created.
#!/bin/sh
. cfg
USER='abc'
PASSWD='abc123'
... (4 Replies)
Please help with the following command
tail -f /appdata/logs/alert_audit517.txt | grep "Sep 02"
The problem I have is with the file name "alert_audit517.txt". The 3 digit number at the end of the file name changes, so I need the file name to use a wildcard. Ive tried alert_audit***.txt, but... (5 Replies)
Hi,
I'm on a Linux machine with a bash shell. I have some apache logs from where I want to extract the lines that match this pattern :
"GET /dir1/dir2/dir3/bt_sx.gif HTTP/1.1"
but where "/dir1/dir2/dir3/bt_sx" may vary , so I would like to grep something like
cat apache.log | grep "\"GET... (2 Replies)
How can i grep for a pattern with wildcard using grep?
I want to identify all the lines that start with SAM and end in .PIPE
IN.TXT
SAM_HEADER.PIPE
SAM_DETAIL.PIPE
SAM_INVOICE.PIPE
Can i do something like
grep SAM*.PIPE IN.TXT (2 Replies)
GNU grep with Oracle Linux 6.3
I want to grep for strings starting with the pattern ora and and having the words r2j in it. It should return the lines highlighted in red below.
But , I think I am not using wildcard for multiple characters correctly.
$ cat someText.txt
ora_pmon_jcpprdvp1... (3 Replies)
I know this is very basic and looks strange to me .
-bash-3.2$ wc -l *.
Result:
51 test.bad
Since my third range after dot is A-Z(upper), how it matched the d( Lower)? i was in an understanding that the above code would not fetch any result unless i have a file with 3 char extension... (4 Replies)
Hello All,
I hope this is the right area. If not, Kindly let me know and I will report in the appropriate spot.
I am needing to find a search pattern that will make the * act as Wildcard in the search pattern instead of being literal.
The example I am using is bzgrep "to=<*@domain.com>"... (5 Replies)
hi anyone
how can use grep with wildcard. for example grep "sample?txt" filename doesn't show sample1txt or grep "sample*txt" filename doesn't show sample123.txt that there is in filename.
many thanks
samad (12 Replies)