grepコマンドを使用して、一致のみを取得しようとしています。grepでのみ一致を取得したい
は、私は、XMLファイルを読んでいると私は唯一の「http://myurl.com/myuri/document」を取得したい
<?xml>
<!-- ..... -->
<location>http://myurl.com/myuri/document</location>
タグの場所のURLを取得したいです。 私はこの作られた:
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>
今、私はこの作られた唯一のURL を取得したい:
curl http://mywebsite.com/file.xml | grep "\<location\>" | grep -oh ">.*<"
を私はほとんど勝ちますhaha
chars>とでURLを受け取りました210
どうすれば一致を得ることができますか?例えば (この例のdoesntの仕事)
curl http://mywebsite.com/file.xml | grep "\<location\>" | grep -oh ">(.*)<"
http://myurl.com/myuri/document
私は、この後にはwgetでVARを使用したいです。 | wget $1
これはgrepとは異なります。 'grep'を使い、結果を' sed'に渡します。 – Mort