0

我有大量文件要添加到灯箱图库中。我生成了缩略图,我只需要让 sed 抓取从“foto”到“bmp”、“jpeg”或“jpg”或“png”的所有内容(我的一些图像的扩展名已锁定,如 PNG、JPG JPEG BMP) 并-thumb在扩展名之前添加到行尾。

做这个

<a href="images/foto (1000).jpeg" rel="lightbox[galeria]" title="Description."><img src="images/
<a href="images/foto (950).bmp" rel="lightbox[galeria]" title="Description."><img src="images/
<a href="images/foto (10).png" rel="lightbox[galeria]" title="Description."><img src="images/
<a href="images/foto (100).JPG" rel="lightbox[galeria]" title="Description."><img src="images/

看起来像这样

<a href="images/foto (1000).jpeg" rel="lightbox[galeria]" title="Description."><img src="images/foto (1000)-thumb.jpeg
<a href="images/foto (950).bmp" rel="lightbox[galeria]" title="Description."><img src="images/foto (950)-thumb.bmp
<a href="images/foto (10).png" rel="lightbox[galeria]" title="Description."><img src="images/foto (10)-thumb.png
<a href="images/foto (100).JPG" rel="lightbox[galeria]" title="Description."><img src="images/foto (100)-thumb.JPG

我已经能够在模式之间获取内容,并将内容添加到行尾,但我无法完成这项工作。

4

1 回答 1

1

这对于您想要的可能太脏了,但这是使用的一种方法GNU awk

awk -F '["./]' '{ print $0 $3 "-thumbs." $4 }' file.txt

结果:

<a href="images/foto (1000).jpeg" rel="lightbox[galeria]" title="Description."><img src="images/foto (1000)-thumbs.jpeg
<a href="images/foto (950).bmp" rel="lightbox[galeria]" title="Description."><img src="images/foto (950)-thumbs.bmp
<a href="images/foto (10).png" rel="lightbox[galeria]" title="Description."><img src="images/foto (10)-thumbs.png
<a href="images/foto (100).JPG" rel="lightbox[galeria]" title="Description."><img src="images/foto (100)-thumbs.JPG
于 2012-09-19T12:33:14.603 回答