Last active
April 21, 2020 20:41
-
-
Save blasterpal/84daf9b8342f92c8b15a8cd5a52a8167 to your computer and use it in GitHub Desktop.
Print a matched group from a file using sed
This file contains hidden or 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
cat graylog-search-result-relative-604800.csv | while read line | |
do | |
echo $line | sed -n -r 's/.*db":([0-9]*\.[0-9]*).*/\1/p' | |
done | |
cat graylog-search-result-keyword-since-april3.csv | while read line | |
do | |
echo $line | sed -n -r 's/.*email":"([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,})",.*/\1/pi' | |
done | |
let linenum=1 | |
cat graylog-slow-query.csv | while read line | |
do | |
let linenum=linenum+1 | |
echo "`echo $line | sed -n -r 's/.*\(([0-9]*\.[0-9]*ms)\).*/\1/p'` || $linenum" | |
done | |
# use it | |
let linenum=1 | |
export wecare=(12 194 195 1109 1692 1885 1906 2204) | |
cat graylog-admin-api-5min.csv | while read line | |
do | |
let linenum=linenum+1 | |
for i in ${wecare[@]}; do | |
if [ $i == $linenum ] | |
then | |
echo $line | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment