Created
November 30, 2016 18:17
-
-
Save chadmayfield/5279cd337292682d5dcdd5a368524708 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oct 24 13:10:56.111039 2016] [core:notice] [pid 13] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' | |
[Mon Oct 24 13:59:21.008651 2016] [core:notice] [pid 18] SELinux policy enabled; httpd running as context system_u:system_r:svirt_lxc_net_t:s0:c664,c840 | |
[Mon Oct 24 13:59:21.009400 2016] [suexec:notice] [pid 18] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) | |
[Mon Oct 24 13:59:21.043636 2016] [ssl:notice] [pid 18] AH01884: Operating in SSL FIPS mode | |
[Mon Oct 24 13:59:21.044086 2016] [ssl:warn] [pid 18] AH01902: Host 10.10.10.7:443: X.509 CRL storage locations configured, but CRL checking (SSLCARevocationCheck) is not enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# quick/dirty matching for a script to scrape output from a logfile looking | |
# for a certain pattern.... done for learning purposes | |
# TODO: parameterize to allow $1 to be match text | |
while read line | |
do | |
if [[ $line =~ AH01884 ]]; then | |
# add text from awk print $2 to array | |
#grants+=("$(echo $line | awk -F "AH01884" '{print $2}')") | |
# use awk to print all but $1 & $2 and add to array | |
grants+=("$(echo $line | awk '{$1=$2=""; print $0}')") | |
fi | |
done < mylogfile.log | |
# begin sample output methods from array | |
# use printf | |
echo "Using printf()" | |
printf ' %s\n' "${grants[@]}"; | |
# use internal field sperator | |
echo "Using \$IFS" | |
( IFS=#39; echo " ${grants[*]}" ) | |
# use a loop to echo each line | |
echo "Using a for loop" | |
for each in "${grants[@]}" | |
do | |
echo " $each" | |
done | |
#EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment