View Full Version : Bash script OR condition

March 2nd, 2007, 12:23 PM
Hi all, probably a simple question.
The following script set my background to a random jpg from the specified folder.

NIMGS=`find /media/commondrive/Pictures/wallpapers -iname '*.jpg' | tr -d ' '`
IMGS=`find /media/commondrive/Pictures/wallpapers -iname '*.jpg' -printf "%p#"`
N=`echo $NIMGS | wc -w`
BGNAME=`echo $IMGS | cut -d '#' -f $N`
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$BGNAME"
gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched"

The probem is that I want to include png's too. Logically that would mean that it should look for *.jpg OR .*png. But how to do that.
Tried ('*.jpg' || '*.png') and '*.jpg' || '*.png' but no luck.
What am I missing?


March 2nd, 2007, 01:00 PM
try this

find . \( -name "*jpg" -o -name "*png" \) -print

March 2nd, 2007, 01:06 PM
Sweet, thats perfect...
Thx a bunch