2012-05-13 148 views
0

我使用leanpub.com並導入了我的博客,但不小心將其留下以導入圖像。我不想這樣,現在我想從大約2000個獨立標記文件中去除圖像。如果你熟悉降價,你就會知道的圖像被指定像這樣從文件中刪除標記文本

![optional alt text](url/link "optional title") 

更新:經進一步檢查一些圖片也鏈接,以便它們都包含這樣的:

[![alt text](image link "title text")](url image links to) 

示例文本

[![Hollywood: An Empire of Their Own (A&E DVD Archives)](images/51EEVBAA32L._SL160_.jpg)Hollywood: An Empire of Their Own (A&E DVD Archives)](http://www.amazon.com/Hollywood-Empire-Their-Own-Archives/dp/B0009HMTEO?SubscriptionId=08NDXT4K5C4JPKBB4702&tag=amz&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B0009HMTEO)This 
"lucid, inviting work of social history" (The New York Times) highlights the 
bold and enduring vision of the Jewish immigrants who founded Hollywood and reinvented American culture. 

回答

0

剛剝離出令牌之間的所有內容![)。請注意,可選的尾部空格很重要,因爲鏈接可以被其他文本包圍。

sed --in-place='.bak' 's/!\[.*)[[:space:]]\?//' [file ...] 
+0

我剛剛添加了一個更新,以防鏈接中包含的圖像。這仍然有效嗎?我還沒有嘗試過。 – Poe

+0

我想你的意思是[。*]不是[。*) – jerrygarciuh

+0

這對於嵌套括號也不起作用(例如,包含一組括號的鏈接) –