-1

I have this file:

Alias name: ciscobas Owner: CN=DI0DGQB2QG9RK8OHMJ5C, O=Duo Security Issuer: CN=DI0DGQB2QG9RK8OHMJ5C, O=Duo Security Valid from: Thu Jun 15 15:08:49 AST 2023 until: Tue Jan 19 06:14:07 AST 2038 Alias name: mobca Owner: CN=Mobily Root CA, OU=Security And Privacy, O=Etihad Etisalat Company - Mobily, L=RIYADH, ST=RIYADH, C=SA Issuer: CN=Mobily Root CA, OU=Security And Privacy, O=Etihad Etisalat Company - Mobily, L=RIYADH, ST=RIYADH, C=SA Valid from: Sat Apr 17 08:13:51 AST 2021 until: Thu Apr 17 08:13:51 AST 2036 Alias name: mobsubca Owner: CN=Mobily IT CA, OU=Security And Privacy, O=Etihad Etisalat Company - Mobily, L=RIYADH, ST=RIYADH, C=SA Issuer: CN=Mobily Root CA, OU=Security And Privacy, O=Etihad Etisalat Company - Mobily, L=RIYADH, ST=RIYADH, C=SA Valid from: Fri Apr 23 06:50:32 AST 2021 until: Wed Apr 23 06:50:32 AST 2031 accessMethod: caIssuers 

And i want it to look like this.

Alias name: ciscobas until: Tue Jan 19 06:14:07 AST 2038 Alias name: mobca until: Thu Apr 17 08:13:51 AST 2036 

After doing this, i will need to check when that date will expire within next 30 days.

3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Oct 25, 2023 at 21:11
  • Please can you check that this post is correct - I've modified the formatting (just changed your copy-pastes to code blocks) - which seems to make more sense if I am understanding what you are looking to do. Commented Oct 25, 2023 at 21:14
  • Also, we are not a script writing service - you should show us what you have tried and where you are failing. Commented Oct 25, 2023 at 21:35

1 Answer 1

0

Here is a partial solution to your question - ie it converts the input to the output -

 egrep "^Alias name: | (.*)until:(.*)" file.name | sed 's/Valid from:\(.*\)until:\(.*\)/\2/' 

It is unclear from your post if you only wanted the first 2 answers, or if your post was truncated. I've not attacked the much more interesting problem of checking if the date expires in the next 30 days. This is a whole different question and is inconsistent with the one you asked. (You will need to parse the output and then match the date. I am sure it can be done with bash - but I don't know that its the correct tool for the job. If you are dead set on this, can we make assumptions about the filesystem - ie that the filesystem can support timestamps?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.