Parameter list in command

Parameter list in command

Post by Zietek Paw » Wed, 08 Sep 1999 04:00:00



Hello,

I have a problem with paremeter list with command on AIX.

Eg. I have a directory  tree like this:

/dir---/subdir1--/one/
       |             |--/two/
       |
       |-/subdir2--/one/
       |             |--/two/
       |
       .
       .
       .
       |-/subdir1000--/one/
                           |--/two/

When I write commands like this:

# find /dir/subdir*/one -name "*" -type f
or
# ls /dir/subdir*/one

I got a message:
ksh: /usr/bin/find: 0403-027 The parameter list is too long.
or
ksh: /usr/bin/ls: 0403-027 The parameter list is too long.

Altough command that gives me the same result:
# find /dir/subdir* -name "*" -type f | grep \/one\/
works fine.

I've tried to use first two command on Linux or SCO, and never have
any problems with directory structure much bigger (over 2000 subdir).

Any hint ?


Computer Communication Systems SA
Wroclaw, Poland

 
 
 

Parameter list in command

Post by Michael Dimitriadi » Wed, 08 Sep 1999 04:00:00


The ksh expands the pattern before invoking the commands find or ls and the
resulting parameter list must not exceed a certain length (somewhere in the
24k-area, i dont no exactly the limit).
So in your 'find /dir/subdir* -name "*" -type f | grep \/one\/' you were
simply lucky because since the pattern is shorter the limit is not reached.
You should try something like

find /dir -name "*" -type f | nawk '/subdir.*one$/ {print}'

Avoid having a pattern in a parameter list whenever there is a possibilty
that the number of matching files is large


: Hello,
:
: I have a problem with paremeter list with command on AIX.
:
: Eg. I have a directory  tree like this:
:
: /dir---/subdir1--/one/
:        |             |--/two/
:        |
:        |-/subdir2--/one/
:        |             |--/two/
:        |
:        .
:        .
:        .
:        |-/subdir1000--/one/
:                            |--/two/
:
: When I write commands like this:
:
: # find /dir/subdir*/one -name "*" -type f
: or
: # ls /dir/subdir*/one
:
: I got a message:
: ksh: /usr/bin/find: 0403-027 The parameter list is too long.
: or
: ksh: /usr/bin/ls: 0403-027 The parameter list is too long.
:
: Altough command that gives me the same result:
: # find /dir/subdir* -name "*" -type f | grep \/one\/
: works fine.
:
: I've tried to use first two command on Linux or SCO, and never have
: any problems with directory structure much bigger (over 2000 subdir).
:
: Any hint ?
:

: Computer Communication Systems SA
: Wroclaw, Poland

 
 
 

Parameter list in command

Post by Norman Levi » Wed, 08 Sep 1999 04:00:00



> Hello,

> I have a problem with paremeter list with command on AIX.

> Eg. I have a directory  tree like this:

> /dir---/subdir1--/one/
>        |             |--/two/
>        |
>        |-/subdir2--/one/
>        |             |--/two/
>        |
>        .
>        .
>        .
>        |-/subdir1000--/one/
>                            |--/two/

> When I write commands like this:

> # find /dir/subdir*/one -name "*" -type f

***>> the shell sees subdir* and expands it.  You have
find /dir/subdir1/one /dir/subdir2/one /dir/subdir3..../dir  you
get the idea.  I think you can specify 4 directories to find
at a time to search.

- Show quoted text -

> or
> # ls /dir/subdir*/one

> I got a message:
> ksh: /usr/bin/find: 0403-027 The parameter list is too long.
> or
> ksh: /usr/bin/ls: 0403-027 The parameter list is too long.

> Altough command that gives me the same result:
> # find /dir/subdir* -name "*" -type f | grep \/one\/
> works fine.

> I've tried to use first two command on Linux or SCO, and never have
> any problems with directory structure much bigger (over 2000 subdir).

> Any hint ?


> Computer Communication Systems SA
> Wroclaw, Poland

--
Norman Levin
vm/dynAmIX inc.