[K12OSN] OT: check case and format of filename
nils at breun.nl
Fri Sep 26 17:12:08 UTC 2008
Rob Owens wrote:
> Since list has been kinda slow lately, I'll test your patience with
> more scripting question. You guys have really helped me learn a lot
> the past couple of days. I've been looking into bash parameter
> expansion, awk, and sed, but I'm not really sure I'm going in the
> I need to check a filename for a particular "format" or "convention".
> File names should look like this:
> In other words:
> 1) They should be all uppercase and numeric before the '--'
> 2) They must contain '--revX', where X is any uppercase letter, and
> 'rev' must be lowercase.
> 3) There is an optional --page# at the end, where # is any number,
> 'page' must be lowercase.
> I can work out the logic of testing for compliance with my rules, but
> I'm not sure how to identify the case of each letter, nor how to split
> the filename up using '--' as the divider.
> Thanks for any advice you might have. By the way, this is to be
> part of
> a bash script (which is to be run on my K12LTSP box).
Do you need a function that returns true or false depending on whether
a string (filename) complies with the format or do you need something
that returns all filenames in a directory that do or do not comply or
something? Did you already figure out that you're probably looking at
using regular expressions? http://www.regular-expressions.info/ has a
lot of info on regular expressions.
Hm, this is starting to feel like work. This is your last free
question, next time I'll send you an invoice. :o)
More information about the K12OSN