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

  • SEARCH
  • Home
  • 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 8201987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:00:27+00:00 2026-06-07T07:00:27+00:00

How do I get Dir[‘*’] to include dotfiles, e.g., .gitignore , but not .

  • 0

How do I get Dir['*'] to include dotfiles, e.g., .gitignore, but not . and ..?

I.e., is there a better way to do:

`ls -A`.split "\n"

perhaps with Dir? The following solutions are close but both include . & ..:

Dir.glob('*', File::FNM_DOTMATCH)
Dir['{.*,*}']

So, the following works:

Dir.glob('*', File::FNM_DOTMATCH) - ['.', '..']

But, is there still a better way to do this?

I’m wondering this to fix line 9 of a Meteor Homebrew Formula.

  • 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-06-07T07:00:28+00:00Added an answer on June 7, 2026 at 7:00 am

    You can’t with Dir[], but you can with Dir.glob, which Dir[] calls:

    Dir.glob("*", File::FNM_DOTMATCH)
    

    You can get rid of the . & .. easily:

    Dir.glob("*", File::FNM_DOTMATCH).tap { |a| a.shift(2) }
    

    But I think it’s probably best to stick with your original way:

    Dir.glob("*", File::FNM_DOTMATCH) - %w[. ..]
    

    (among other ways)

    However, if you don’t require a more sophisticated glob than *, Dir#children may be all you need (can always further filter/grep the results if more filtering is needed):

    Dir.children('.')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems to not get past this step: [ 16%] Building CXX object src/CMakeFiles/hphp_runtime_static.dir/lib/system/gen/sys/dynamic_table_func.no.cpp.o
I run the following command unsuccessfully dir and I get zsh: correct 'dir' to
Right now I have this GET request which works in Chrome but not in
I have used the following code to get the document root. $path = get_file_dir();
I get an EOFError end of file error. when running PrivatePub.publish_to(/dir/file, Some Text) within
Problem: to get the command working here. My domain is http://cs.edu.com/user/share_dir , but I
I got this colored dir script from http://tasteofpowershell.blogspot.com/2009/02/get-childitem-dir-results-color-coded.html : function ls { $regex_opts =
this code is get the templates/blog1/page.html in b.py: path = os.path.join(os.path.dirname(__file__), os.path.join('templates', 'blog1/page.html')) but
I like to get a dir listing in php glob(*.jpg); or $dir = '.';
This is probably something simple, but I can't figure out why I can't get

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.