From: osiris on
I have a slew of files in one directory where
most of the filenames are 4 characters long.
How can I use the Bourne shell (only)
to specify those 4-character filenames?

I can't use an asterisk since some files are
longer than 4 characters.

I can't use any other shell other than the Bourne shell
on this particular computer.

The 4-char filenames are all numeric so I tried

grep "$re" "$dir/[0-9][0-9][0-9][0-9]"

but the Bourne shell claims:

No such file or directory

Thanks for your help.
From: pk on
osiris(a)abydos.kmt wrote:

> How can I use the Bourne shell (only)
> to specify those 4-character filenames?

$ ls
11111 2222 33333 4444 55555 file1 file2 file3 moo
$ echo ????
2222 4444

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
From: osiris on

pk <pk(a)pk.invalid> wrote:
>osiris(a)abydos.kmt wrote:
>
>> How can I use the Bourne shell (only)
>> to specify those 4-character filenames?
>
>$ ls
>11111 2222 33333 4444 55555 file1 file2 file3 moo
>$ echo ????
>2222 4444

Ooops! I did use that but then I discovered that there were
files that were non-numeric that were also 4 characters long
so then I tried "[0-9][0-9]??" and from there went to
"[0-9][0-9][0-9][0-9]" -- so I still don't have a solution
unless I use a loop which I was hoping not to do.

Many thanks.
From: pk on
osiris(a)abydos.kmt wrote:

> Ooops! I did use that but then I discovered that there were
> files that were non-numeric that were also 4 characters long
> so then I tried "[0-9][0-9]??" and from there went to
> "[0-9][0-9][0-9][0-9]" -- so I still don't have a solution
> unless I use a loop which I was hoping not to do.

It works regardless of numeric/alphabetic characters:

$ ls
1111 45gh abcd dfg67 mn18 ppppp s\ ss
$ echo ????
1111 45gh abcd mn18 s ss

It would help, however, if you told us what you're trying to do exactly.

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
From: Janis on
On 2 Apr., 11:28, osi...(a)abydos.kmt wrote:
> pk <p...(a)pk.invalid> wrote:
> >osi...(a)abydos.kmt wrote:
>
> >> How can I use the Bourne shell (only)
> >> to specify those 4-character filenames?
>
> >$ ls
> >11111  2222  33333  4444  55555  file1  file2  file3  moo
> >$ echo ????
> >2222 4444
>
> Ooops!  I did use that but then I discovered that there were
> files that were non-numeric that were also 4 characters long
> so then I tried "[0-9][0-9]??" and from there went to
> "[0-9][0-9][0-9][0-9]" -- so I still don't have a solution
> unless I use a loop which I was hoping not to do.

Don't include the [0-9][0-9]?? inside the quotes; the shell won't
expand it there. Instead...

grep "$re" "$dir"/[0-9][0-9]??


Janis

>
> Many thanks.