2

I am trying to figure out if there exists any command or combination of commands that can display all .png files with a given prefix.

For instance,

In one of my directories, there exist files

life_001.png
life_002.png
.
.
.
life_020.png
and
death_001.png
death_002.png
.
.
.
death_010.png

How can I display all life_***.png files simultaneously or consecutively using a command in linux terminal?

Thank you!

0

1 Answer 1

4

To open all matching files at the same time, in the default application for their respective file type, you can use xdg-open in a for-loop:

for f in life_*.png ; do xdg-open "$f" ; done

Note that because xdg-open opens the file in a separate process and returns immediately, this might open as many instances of your viewer application as there are files matching the pattern in rapid succession, which could strain your system resources.

To open them sequentially, you'd have to call your viewer application directly and in the foreground, so that the next picture only opens as soon as you close the previous instance. In case of the "Eye Of Gnome" viewer eog, you should do:

for f in life_*.png ; do eog "$f" ; done

Not the answer you're looking for? Browse other questions tagged .