I made a short script to help me learn bash. The function in question is:
Code:
watchVideo() {
# Create alphabetical array of video files by recursively scanning $HOME.
video=$(find $HOME/* -name *.flv |sort; find $HOME/* -name *.mpg |sort; find $HOME/* -name *.avi |sort)
PS3=">>> Choose; hit Enter. > "
echo ""
echo " 0) Return to Main Menu."
# Display all video files.
select choice2 in $video
do
if [ $choice2 ==0 ]; then
hello # If $USER chooses 0, return to Main Menu.
else :
exec mplayer $choice2
break
fi
done
exit 0
}
I just want 1 command for the
video variable: find's -name parameter accepting a list of filenames prefaced with * instead of the same command 3 times. I've tried
Code:
find $HOME/* -name [*.mpg,*.flv,*.avi] | sort
and
many variations, but to no avail. How can this be done? BTW, this is on Ubuntu 8.10.
*****
Update: I tried "find -name $HOME/*/[*.mpg, *.flv, *.avi] | sort" which gave:
Code:
find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name `/home/agrestic/*/[*.mpg,'' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'.
And "find -wholename $HOME/*/[*.mpg, *.flv, *.avi] | sort" which gives:
Code:
find: paths must precede expression: *.flv,
So still no clue.
TIA.