× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On one system the command
find /dir1/dir2/dir3/dir4/* returns a list of files in the last directory
in the path.

The * character is interpreted by QShell, not by the FIND utility. QShell will expand the wildcard into a list of filenames, and pass that list of filenames to the FIND utility instead.


So if I have a directory containing files named file1.txt file2.txt and file3.txt and I say "find /mydir/*" Qshell will expand the command line to read "find /mydir/file1.txt /mydir/file2.txt /mydir/file3.txt" and then it will run find with those 3 parameters. ("Arguments" is another name for parameters)

On the other system the same command returns
qsh: 001-0085 Too many arguments specified on command.

There's a limit to how many arguments can be specified for a given command. So, if there are 800 files in a directory, and you type "find /mydir/*" then it creates a really long command with all of those 800 files. If that's more files than are allowed, you'll get the "too many arguments" error.



Even if I cd into the end directory and just do find * I still get the same result

Doing a CD to the directory and "find *" should result in the exact same number of files as "find /thedir/*" does. I don't understand your point here.


so I'm assuming there is some sort of command default coming into
play? Even after uninstalling QSHELL and restoring the licensed program
from the system that does work I still get the same result. Both systems
are at V5R2 with the same cume and group levels.

Shrug... it's really easy to fix, don't use * in the find command. It really doesn't make sense there anyway. The first argument to find should be the name of a directory, not a list of files in that directory!


In other words, do it like this:

     find /dir1/dir2/dir3/dir4

That will list all of the files in dir4 and any subdirectories below dir4. You don't need the * character.

If you need to subset the list of files by filename, you should use the -name switch to do that. If you use a wildcard in that, make sure you put it in single quotes so that it'll be interpreted by FIND instead of by QShell.

For example, DON'T do the following:

     find /mydir -name *.txt

because QShell will expand *.txt into a list of files, and what the FIND utility will actually see will be the following:

     find /mydir -name file1.txt file2.txt file3.txt

That's a problem, because find will think that "file2.txt" is another switch that you're wanting to pass to it, and it doesn't know how to deal with a swtich called "file2.txt" so it will return an error.

On the other hand, DO do it this way:

    find /mydir -name '*.txt'

The single quotes tell QShell not to do any special processing for the characters in the quotes. That way, the FIND utilty will actually receive the characters '*.txt' as the argument to the -name switch, and will know how to deal with it.

This is true of any Unix shell, and is not specific to QShell.

Good luck!

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.