I have a useful script greplog
that does:
grep -Eh --color $1 /var/log/apache2/other_vhosts_access.log{.1,}
so I can easily search like this:
greplog index.php
But
greplog "POST /test.php"
doesn't work: it searches for POST
or /test.php
whereas it should be a full pattern search, with the space included. Why?
Why isn't $1
replaced by "POST /test.php"
? Indeed this works fine:
grep -Eh --color "POST /test.php" /var/log/apache2/other_vhosts_access.log{.1,}
$1
is replaced byPOST /test.php
, not"POST /test.php"
- wrap your parameter in quotes:"$1"
– Panki Dec 22 '20 at 09:23