Hi all I'm trying to use a command (anything but my best guess now is 'find'). I want to list files that end in the number 8-16 if they exist for example finding names 5-9 is easy: $ find /dev/vc -name [5-9] /dev/vc/9 /dev/vc/8 /dev/vc/7 /dev/vc/6 /dev/vc/5 I'm having problems though with numbers higher than 10. $ find /dev/vc -name [5-16] /dev/vc/6 I only get 6 back.. Any ideas? -thanks
On Tue, May 17, 2005 at 07:24:08PM -0400, Karl Hiramoto wrote:
I want to list files that end in the number 8-16 if they exist
I'm having problems though with numbers higher than 10.
$ find /dev/vc -name [5-16] /dev/vc/6
I only get 6 back..
Any ideas?
Yeah. [...] indicates a character list, not numbers. So [5-16] means "all characters between ASCII value of '5' and ASCII value of '1' (none, you'd want 1-5, it doesn't work in reverse), and ASCII value of '6'. There's no logic about numbers in globs that I know of, so you have to work this as 5-9 and 10-16. Something like this ought to work: find /dev/vc -name "*[^0-9][5-9]" -o -name "*[^0-9]1[0-6]" -- Randomly Generated Tagline: Look both ways before you cross the network.
==> Regarding [Wlug] Find command -name; Karl Hiramoto <karl@hiramoto.org> adds: karl> Hi all I'm trying to use a command (anything but my best guess now karl> is 'find'). karl> I want to list files that end in the number 8-16 if they exist karl> for example finding names 5-9 is easy: karl> $ find /dev/vc -name [5-9] /dev/vc/9 /dev/vc/8 /dev/vc/7 /dev/vc/6 karl> /dev/vc/5 karl> I'm having problems though with numbers higher than 10. karl> $ find /dev/vc -name [5-16] /dev/vc/6 karl> I only get 6 back.. karl> Any ideas? There are about a billion different ways to do this, and everyone you talk to will do it differently, I'd bet. For starters, this should work: find /dev/vc | grep -E "*([5-9]|1[0-6])" You should take a look at the regex(7) man page. -Jeff
participants (3)
-
Jeff Moyer
-
Karl Hiramoto
-
Theo Van Dinter