Sed: Difference between revisions

From Anthony Pastor Wiki Notes - Verba volant, scripta manent
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Print a pattern between two (exclusive) words:
*Print a pattern between two (exclusive) words:
 


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 7: Line 6:
</syntaxhighlight>
</syntaxhighlight>


 
We only want the <i>routedTo</i> information:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ ./ovh-api-bash-client.sh --url "/ip/45.102.38.141" | sed -e 's/.*serviceName":"//' -e 's/"},"ip":.*$//'
$ ./ovh-api-bash-client.sh --url "/ip/45.102.38.141" | sed -e 's/.*serviceName":"//' -e 's/"},"ip":.*$//'
ns612429.ip-45-102-38.eu
ns612429.ip-45-102-38.eu
</syntaxhighlight>
</syntaxhighlight>

Revision as of 23:41, 20 April 2015

  • Print a pattern between two (exclusive) words:
$ ./ovh-api-bash-client.sh --url "/ip/45.102.38.141"
200 {"organisationId":null,"country":"fr","routedTo":{"serviceName":"ns612429.ip-45-102-38.eu"},"ip":"45.102.38.141/32","canBeTerminated":true,"type":"failover","description":null}

We only want the routedTo information:

$ ./ovh-api-bash-client.sh --url "/ip/45.102.38.141" | sed -e 's/.*serviceName":"//' -e 's/"},"ip":.*$//'
ns612429.ip-45-102-38.eu