Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm trying to find files with multiple extensions in a shell script

Tags:

linux

shell

Here's what I have so far

DIR="/home/username/Pictures/Wallpapers"

while [ 1 -eq 1 ]
do
    PIC=$(ls $DIR/*.jpg | shuf -n1)
    PIC1="file://"$PIC

    gsettings set org.gnome.desktop.background picture-uri $PIC1
    sleep 30;
done

The script works, but I can't figure out how to expand it to find other file extensions, like png or gif in addition to jpg.

like image 215
bbbgscott Avatar asked May 01 '12 20:05

bbbgscott


1 Answers

How about using find?

find $DIR -name \*.jpg -o -name \*.png -o -name \*.gif -print
like image 172
Oliver Avatar answered Nov 10 '22 10:11

Oliver