LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-18-2016, 10:02 PM   #1
benjam1nrk
LQ Newbie
 
Registered: Mar 2010
Distribution: CentOS
Posts: 24

Rep: Reputation: 1
Unhappy Grep. Driving myself Insane.


I am running a command that looks like this:
Code:
./ssl-cert-check.sh -s oc.mydomain.com -p 443
It produces this output:
Code:
Host                                            Status       Expires      Days
----------------------------------------------- ------------ ------------ ----
oc.mydomain.com:443                        Valid        Feb 16 2017  90
I want to extract the "Days" from the output, 90 in this instance.

I have been unsuccessful using the following bash command
Code:
./ssl-cert-check.sh -s oc.visionsxtreme.com -p 443|grep '/([0-9])+$/m'
This regex appears to work in the web regex testers, but I cannot produce the desired results in the shell. What am I doing wrong, besides driving myself crazy?!

Thank you. Ben
 
Old 11-18-2016, 10:18 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,407

Rep: Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011
Over thinking it way too much - try "grep -oE '[0-9]+$' ".

Last edited by syg00; 11-18-2016 at 10:21 PM. Reason: random bracket removed
 
1 members found this post helpful.
Old 11-18-2016, 10:23 PM   #3
benjam1nrk
LQ Newbie
 
Registered: Mar 2010
Distribution: CentOS
Posts: 24

Original Poster
Rep: Reputation: 1
Thank you, but running the following command still does not produce any output.
Code:
./ssl-cert-check.sh -s oc.mydomain.com -p 443|grep -oE '([0-9])+$'
 
Old 11-18-2016, 10:27 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,407

Rep: Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011Reputation: 2011
The reason for things like that is generally whitespace at end of line - add it to your regex.
 
2 members found this post helpful.
Old 11-18-2016, 10:58 PM   #5
benjam1nrk
LQ Newbie
 
Registered: Mar 2010
Distribution: CentOS
Posts: 24

Original Poster
Rep: Reputation: 1
Thank you, I should have realized some white space may have existed. The following worked:
Code:
./ssl-cert-check.sh -s oc.mydomain.com -p 443|grep -oE '([0-9])+ *$'
I appreciate the help!
 
Old 11-19-2016, 01:05 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,483

Rep: Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864Reputation: 2864
A little longer, but this type of thing is well suited to awk:
Code:
./ssl-cert-check.sh -s oc.mydomain.com -p 443 | awk '/[0-9]/{print $NF}'
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] SANE is driving me insane! pchristy Slackware 19 12-16-2014 02:02 PM
snd_hda_intel driving me insane TrevorBradley Linux - Hardware 1 02-11-2007 08:18 PM
Samba driving me insane Lorend Linux - Newbie 7 02-16-2005 06:26 PM
Mplayer Driving Me Insane!!!!! njschroe Linux - Software 7 01-24-2005 05:31 PM
Sendmail is driving me insane. Please help me. ecroskey Linux - Newbie 1 03-02-2003 06:02 AM


All times are GMT -5. The time now is 05:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration