-1

I am trying to cat all png files in a directory and pipe them to the ffmpeg command:

cat *.png | ffmpeg

it works but I now wanto to exclude from the list all png file beginning with the prefix 'legend_'. How do I achieve this? I know that using ls I can type:

ls -I legend_* -I *.jpg

I found info about grep, ls , etc but there are confusing information regarding the command cat and none seem to work like using

!(legend_)
! -name legend_
Dino
  • 1,307
  • 2
  • 16
  • 47
  • Possible duplicate of [List files not matching a pattern?](https://stackoverflow.com/q/8525437/608639), [List files not matching given string in filename](https://unix.stackexchange.com/q/51981/56041), [How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?](https://stackoverflow.com/q/216995/608639), etc. – jww Aug 22 '18 at 13:39

1 Answers1

0

You can use find:

find . -name '*.png' ! -name 'legend_*' -exec cat {} \; | ffmpeg

With bash, using the extglob option, you can write:

shopt -s extglob
ls !(legend_*).png

Since the extglob option is not POSIX conform, meaning it is not guaranteed to work in a POSIX shell I would recommend to use find.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266