Have documents stored in a file system which includes “daily” directories, e.g. 20050610. In a bash script I want to list the files in a months worth of these directories. So I’m running a find command find <path>/200506* -type f >> jun2005.lst. Would like to check that this set of directories is not a null set before executing the find command. However, if I use if[ -d 200506* ] I get a “too many arguements error. How can I get around this?
Have documents stored in a file system which includes daily directories, e.g. 20050610. In
Share
Your “too many arguments” error does not come from there being a huge number of files and exceeding the command line argument limit. It comes from having more than one or two directories that match the glob. Your glob “200506*” expands to something like “20050601 20050602 20050603…” and the
-dtest only expects one argument.The answer by zed_0xff is on the right track, but I’d use a different approach:
The position of the quotes in
"$path"/$globversus"$path/$glob"is essential to this working.Edit:
Corrections made to exclude files that match the glob (so only directories are included) and to handle the very unusual case of a directory named literally like the glob (“200506*”).