我想使用grep命令只获得匹配。想要得到匹配grep
我读一个XML文件,我想在网址标签位置
<?xml>
<!-- ..... -->
<location>http://myurl.com/myuri/document</location>
我只想得到“http://myurl.com/myuri/document”。 我做了这个:
curl http://mywebsite.com/file.xml | grep "\<location\>"
我收到完整标签:
<location>http://myurl.com/myuri/document</location>
<location>http://myurl.com/myuri/document2</location>
<location>http://myurl.com/myuri/document3</location>
现在,我想只有 我做了这个网址:
curl http://mywebsite.com/file.xml | grep "\<location\>" | grep -oh ">.*<"
和我差不多赢哈哈
我收到了带有字符的网址>和<
>http://myurl.com/myuri/document<
我怎样才能得到匹配? 例如(这个例子不工作)
curl http://mywebsite.com/file.xml | grep "\<location\>" | grep -oh ">(.*)<"
http://myurl.com/myuri/document
我想使用var中的wget在此之后。像| wget $1
这不仅仅是grep的用处。使用'grep',然后将结果传递给'sed'。 – Mort