I have a file as below:
JavaScript
x
Thumb Sri Lanka/Anuradhapura/Thumb Anuradhapura.jpg
Thumb Sri Lanka/Anuradhapura/vtour/panos/Anuradhapura.tiles/mobile/pano_b.jpg
Thumb Sri Lanka/Anuradhapura/vtour/panos/Anuradhapura.tiles/mobile/pano_d.jpg
Thumb Sri Lanka/Anuradhapura/vtour/panos/Anuradhapura.tiles/mobile/pano_f.jpg
Thumb Sri Lanka/Anuradhapura/vtour/panos/Anuradhapura.tiles/mobile/pano_l.jpg
Thumb Sri Lanka/Anuradhapura/vtour/panos/Anuradhapura.tiles/mobile/pano_r.jpg
Thumb Sri Lanka/Anuradhapura/vtour/panos/Anuradhapura.tiles/mobile/pano_u.jpg
Thumb Sri Lanka/Anuradhapura/vtour/plugins/fps.xml
Thumb Sri Lanka/Anuradhapura/vtour/plugins/gyro2.js
I need to delete all lines except the first line, which means that lines should not be deleted if it contains Thumb[any characters except /].jpg
.
I try to use sed
to do this but I don’t know how to write the regex.
I’ve tried like this: sed -i -e '.*Thumb^(/).jpg!d' file
but it doesn’t work.
Advertisement
Answer
If filename has to start with Thumb and then one or more charaters (without slash) and and with jpg, you can use regex like this one:
JavaScript
Thumb[^/]*.jpg