Re: bash 1 liner help
On Wed, 2004-10-13 at 22:48, Lance Hoffmeyer wrote:
> I have a set of files:
>
>
> 05file.ogg
> 06file.0gg
> 07file.0gg
> 08file 1.ogg
> 09This file 2.ogg
> 10 This is a file 3.ogg
> 11 another file.ogg
> 12 file.ogg
> 13 file.ogg
>
> I wish to play only the file 08-12*.ogg.
> If I wanted to play files 07-09 I would
> do something like
>
> mplayer 0[7-9]*.ogg
>
> How can I use regular expressions to play files
> 08-12?
>
Shell glob matching is not really regular expression matching. If you
really want to use regular expressions, you'll need to use grep, awk,
sed, or something else. Are you just trying to play a few oggs, or are
you trying to do something fancy - ie. something that can be used to
select a variable as opposed to a fixed range of files?
you could try one of the following (all untested):
ls * |grep -E '(0[89]|1[0-2])' |xargs -i^ mplayer ^
mplayer `ls * |grep -E '(0[89]|1[0-2])'`
mplayer `ls * |sed -e '1,3D' -e '13~1D'`
of course...rather than doing all that, it might be easier to do:
mplayer 0[89]*.ogg; mplayer 1[0-2]*.ogg
or
mplayer {08,09,10,11,12}*.ogg
-davidc
Reply to: