bash - Write command that outputs all JPG images in directory with specific word in file name -


how write command outputs of jpeg images in directory contain word “red” file named “red_photos.txt”.

generating files containing red easy; can pattern *red*. tricky part finding out whether jpeg file or not. like

for f in *red*   if file $f | fgrep -q ' jpeg '       echo $f >>red_photos.txt   fi done 

two issues improvement left exercise (because not directly related question):

  1. if there many files containing red, might "arg list long" error.

  2. if there no file containing red, might error message saying wildcard not match files (depending on settings in bash scripts).


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -