1
這裏是我當前的grep:grep通過並返回href的內容如果匹配?
grep -l -R "battle/" * > /home/results.txt
(This returns the files that it is in)
我想通過上面的文件看,找到實例「戰鬥/」,然後編譯什麼鏈接它指向一個列表。
例如:
<a href="http://www.site.com/battle/index.php">Index</a>
<a href="http://www.site.com/battle/contact.php">Contact</a>
<a href="http://www.site.com/battle/go/here/folder/file.php">Long weird path</a>
而且我想grep的返回結果,像這樣:
http://www.site.com/battle/index.php
http://www.site.com/battle/contact.php
http://www.site.com/battle/go/here/folder/file.php
基本上,我們有聯繫的,我們要刪除一個文件夾內頁,所以我們要找到哪些鏈接仍然在這些網頁中使用。
我想爭取戰鬥/並返回href內的整個路徑。
然後我想要結果輸出到我的results.txt文件。
我該如何去做這個grep?謝謝:)
好的。 +1我可能會添加`href =「...」`來獲得像''href =「[^」] */battle/[^「] *」`然後``| sed`去除可以捕獲相對URL的href和引號。取決於我想成爲多麼挑剔。 – 2011-12-14 00:52:06