I am trying to extract some URLs from a web page using cURL command. Initially, I use the cURL command as below. curl www.website.com/Now, the website contains links to some other websites which am interested in extracting. So, I do a grep on the cURL command as below. curl www.website.com/ | grep <a href= > new1.txtIt is extracting all lines which have <a href= in them. But am particularly interested only in lines which start with <a href= and end with title=How can I modify the grep command?
grep command in curl
grep
This should work:curl www.website.com/ | grep '^<a href=.*title=$' > new1.txtThis will select all lines that begin with <a href= and end in title=Just saw Terdon's comment. You can use -P option with grep and make a non-greedy aka lazy alternative as follows:curl www.website.com/ | grep -P '^<a href=.*?title=$' > new1.txt