Re: Parsing a file name in the shell
On Wed, 2002-02-06 at 10:51, Ron Johnson wrote:
> Try:
> ls [0-9]*
>
> This is a minimalistic use of Regular Expressions. A simple script to
> delete these sub-directories might be:
> #!/bin/sh
> for i in `ls [0-9]*`; do
> echo $i
> rm -rf $i
> done
>
Thanks, that is exactly what I was looking for. For everyone else's
benefit, the ls command needs a '-d' so the directory names are printed.
The default for 'ls *' is to print the directory name followd by a colon
and new line. So it should be `ls -d [0-9]*`.
Thanks again, I was stuck thinking that Bash had to have a way to parse
the names returned instead of using something that already does.
Reply to: