Showing posts with label Curl and egrep Stuffs. Show all posts
Showing posts with label Curl and egrep Stuffs. Show all posts

Thursday, 28 February 2013

Curl and egrep Stuffs



Curl and egrep Stuffs
egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' file.txt


egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'

Check mail on Linux prompt:
curl -u <gmail username>:<password> --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p"

curl -u <gmail username>:<password> --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/'

curl -u <gmail username>:<password> --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/$2 - $1/'


cd /data1/app/oracle/diag/tnslsnr/domU-12-31-38-02-59-A1/listener/alert
find . -mtime -1 -type f | xargs cat * | grep '07-OCT-2009' | egrep -o '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'  | sort | uniq -c | sort -k1 | awk '{
                      switch($2){
                      case "10.211.X.X":
                      {print "node1(10.211.X.X) :=> "$1}
                  case "10.211.71.X":
                      {print "node2(10.211.71.X) :=> "$1}
                  case "10.252.107.X":
                      {print "node31(10.252.107.X) :=> "$1}
                  case "10.254.23.X":
                      {print "node4(10.254.23.X) :=> "$1}
                      default:
                          {print "OTHER $2 :=> "$1}
                  }
                      }'


egrep -o '\b[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b' access.log | sort -u

if ($2 == "10.211.X.X") {printf "%-30s:=>%-10d node1 \n",$2,$1}
                      else if ($2 == "10.211.X.X") {printf "%-30s:=>%-10d Node2 \n",$2,$1}
                      else if ($2 == "10.252.X.X") {printf "%-30s:=>%-10d Node3 \n",$2,$1}
                      else if ($2 == "10.254.X.X") {printf "%-30s:=>%-10d Node4 \n",$2,$1}
                      else {printf "%-30s:=>%-10d Other \n",$2,$1}
                      }'