1

How can I cut a string from the whois command with PHP on CentOS Linux?

I just want to cut from Domain Name: line to the >>>Last update...<<< line.

My code:

<?php
$output = shell_exec('whois facebook.com');
$result = preg_split('/\n\n/', trim($output));
var_dump($result);
?>
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Anurak Jairak
  • 25
  • 1
  • 6

1 Answers1

0

How about using sed:

whois facebook.com | sed -n '/^Domain names/,/^>>> Last update/p'

This will get all lines between the line starting with Domain names and line starting with >>> Last update

erikvimz
  • 5,256
  • 6
  • 44
  • 60