Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This happens in cygwin (CYGWIN_NT-5.1 MYPC 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin)

First command, ls *.py shows nothing

$ ls *.py
ls: cannot access *.py: No such file or directory

First command, ls *.py runs in the same location, shows the following

$ ls *py
LICENSE.txt    _cpchecker.pyc   _cperror.pyc          _cptree.pyc         favicon.ico   _cpserver.pyc          lib
__init__.pyc   _cpconfig.pyc    _cplogging.pyc  _cpwsgi.pyc         process    scaffold
_cpcgifs.pyc   _cpdispatch.pyc   _cptools.pyc          _cpwsgi_server.pyc  wsgiserver      _cprequest.pyc            cherryd

These are files in a subdirectory cherrypy

I did not alias ls in any way (running /usr/bin/ls gives the same results)

So, the question, why the difference? I do not expect ls to run recursively without the -R flag

share|improve this question
up vote 6 down vote accepted

This is because running ls with a folder name will list the contents of the folder(s) that match your argument.

Using * as a wildcard, any folders ending in py would have their contents listed, such as cherrypy, crappy, bumpy etc.

If multiple folders match the criteria, it will show you the folder names as well:

[~/ex]$touch bumpy/1
[~/ex]$touch sloppy/2
[~/ex]$touch cherrypy/3 cherrypy/4 cherrypy/5
[~/ex]$ls *py

3  4  5


You did not have any folders or files directly in your current folder which ended in .py when you ran the first command, hence the output.

share|improve this answer
Thanks, John! Now it is obvious! :-) – Anthony Kong Oct 15 '10 at 5:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .