Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 826845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:28:45+00:00 2026-05-15T03:28:45+00:00

Have documents stored in a file system which includes daily directories, e.g. 20050610. In

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:28:46+00:00Added an answer on May 15, 2026 at 3:28 am

    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 -d test only expects one argument.

    $ mkdir test
    $ cd test
    $ mkdir a1
    $ [ -d a* ]    # no error
    $ mkdir a2
    $ [ -d a* ]
    -bash: [: a1: binary operator expected
    $ mkdir a3
    $ [ -d a* ]
    -bash: [: too many arguments
    

    The answer by zed_0xff is on the right track, but I’d use a different approach:

    shopt -s nullglob
    path='/path/to/dirs'
    glob='200506*/'
    outfile='jun2005.lst'
    dirs=("$path"/$glob)  # dirs is an array available to be iterated over if needed
    if (( ${#dirs[@]} > 0 ))
    then
        echo "directories found"
        # append may not be necessary here 
        find "$path"/$glob -type f >> "$outfile"
    fi
    

    The position of the quotes in "$path"/$glob versus "$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*”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that uses a UITableView to list documents which are stored
I have a application which stores documents on the file system (PDF, WORD etc)..
I have a web page that displays a list of documents stored on the
I have a java web application which needs to upload files and we want
I have a sharepoint with a lot of documents stored in it. I would
I have stored images from the net like this Documents/imagecache/domain1/original/path/inURI/foo.png Documents/imagecache/domain2/original/path/inURI/bar.png Documents/imagecache/... Documents/imagecache/... Now
I have stored the videos and the thumbnail images of the videos in Documents
We have a system were we would like to store about 100M documents. We
I have text documents like the following which contain single and multiple variables: title::
I have an nascent iPad application, which stores documents internally on the device in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.