|
Thanks Scott, That actually makes sense now. I was tring to change down to the directory and just do find * because I thought perhaps the number of directories in the path was causing the too many arguments error, but now I see how it works. I only know a little Unix (just enough to be dangerous really!). I think the person doing this probably knows even a little bit less than me and was just playing with the find command. Personally I would have just done an ls in this case, but it's good to try new things! I tried the command with find /dir1/dir/dir3/dir4/ (ie, without the wildcard), and it works perfectly. We're about to start looking after some AIX partitions on an i5, so I might paste Joe's quote "The shell expands everything. The shell expands everything. The shell expands everything (unless it's in quotes).." on the wall. Many thanks for your help Adam Driver Technical Consultant Kaz Technology Services www.kaz-group.com Phone: +61 2 9844 0386 Fax: +61 2 9281 5261 date: Thu, 10 Feb 2005 02:53:17 -0600 (CST) from: Scott Klement <midrange-l@xxxxxxxxxxxxxxxx> subject: Re: QSHELL question for find command > 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.
As an Amazon Associate we earn from qualifying purchases.
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.