1

How do I fetch only the links from my file shown below:

Jun 15 16:26:21 dnsmasq[1979]: query[A] fd-geoycpi-uno.gycpi.b.yahoodns.net from 192.168.1.33 

Jun 15 16:26:30 dnsmasq[1979]: query[A] armdl.adobe.com from 192.168.1.24

Jun 15 16:26:32 dnsmasq[1979]: query[A] updates.installshield.com from 192.168.1.118

Note: the links may or may not start with "www." or end with ".com" (example: armdl.adobe.com, fd-geoycpi-uno.gycpi.b.yahoodns.net) but the "query[A]" before the link and "from" after the link remains same for every string. Thank you.

5
  • 3
    Maybe s.split()[5]? Well, the "query[A]" before the link and "from" after the link remains same for every string means you just want to extract a string between two strings, right? Closing as a dupe. Commented Jun 22, 2018 at 7:04
  • s.split()[5] should work. Commented Jun 22, 2018 at 7:06
  • @WiktorStribiżew yes exactly I want to extract the string between the given claws... Commented Jun 22, 2018 at 7:07
  • 1
    I have found 2 SO threads that answer your question. If you decide to use a regex, do not forget to escape [ in the pattern to match a literal [. Commented Jun 22, 2018 at 7:11
  • 1
    Thank you @WiktorStribiżew it worked Commented Jun 22, 2018 at 8:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.