2012-05-13 150 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

这对于嵌套括号也不起作用(例如,包含一组括号的链接) –