2012-05-13 3 views
0

leanpub.com을 사용하고 있으며 내 블로그를 가져 왔지만 우연히 이미지를 가져 오게했습니다. 지금은 약 2,000 개의 개별 마크 업 파일에서 이미지를 제거하고 싶습니다. 당신이 이미지를 알 인하에 익숙하다면 같은파일에서 스트립 마크 다운 텍스트

![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

중첩 된 대괄호 (예 : 대괄호가 들어있는 링크)에는이 기능이 작동하지 않습니다. –