Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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    _cpserver.py          _cptree.pyc         favicon.ico
__init__.py    _cpconfig.py     _cplogging.py   _cpserver.pyc         _cpwsgi.py          lib
__init__.pyc   _cpconfig.pyc    _cplogging.pyc  _cpthreadinglocal.py  _cpwsgi.pyc         process
_cpcgifs.py    _cpdispatch.py   _cpmodpy.py     _cptools.py           _cpwsgi_server.py   scaffold
_cpcgifs.pyc   _cpdispatch.pyc  _cprequest.py   _cptools.pyc          _cpwsgi_server.pyc  wsgiserver
_cpchecker.py  _cperror.py      _cprequest.pyc  _cptree.py            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

1 Answer 1

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.