I would like to tail all of the files in directory with the exception of files that include a certain string in their filename. Also, I want to highlight certain words that are included within the files as the command is running.
This is for CentOS specifically regarding tailing all of the domlogs or httpd access logs.
While these work directly via bash, they don't work when included in a script.
When added to a script I also add #!/bin/bash before the following code snippet.
This is the command I am using:
!#/bin/bash
export GREP_COLOR='1;37;41'
tail -f /var/log/apache2/domlogs/!(*bytes*) | grep --color=auto -E '(^|Ubuntu|xmlrpc|spider|spider|python|crawler|Crawler|wp-login|wp-admin|zoom)'
This fails and throws an error when it hit's the first (.
I am expecting it to go ahead and display all of the domlogs with highlighted text.
Extended wildcards are not enabled by default, you need to use shopt
to enable them.
#!/bin/bash
shopt -s extglob
export GREP_COLOR='1;37;41'
tail -f /var/log/apache2/domlogs/!(*bytes*) | grep --color=auto -E '(^|Ubuntu|xmlrpc|spider|spider|python|crawler|Crawler|wp-login|wp-admin|zoom)'