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

I'm facing the following problem:


sh-3.2$ ls -R
#dir1  #dir2

f1  f2  f3

f1  f2  f3


sh-3.2$ ls #dir1
#dir1  #dir2

As seen in Output1 the directory #dir1 has file f1 f2 and f3 but when I do a ls on the directory I get a different output as seen in Output2 Output2 seems to suggest that #dir1 has directories like #dir1 #dir2.

What is going on here? Is this some cyclic link?

share|improve this question

migrated from Sep 5 '10 at 14:09

This question came from our site for professional and enthusiast programmers.

Nice to see you got a good answer, but I've voting to move this to Super User which I believe is a more appropriate site... – dmckee Sep 5 '10 at 4:05

# is a shell meta char which marks the beginning of a comment. Hence

ls #dir1

is effectively same as


which lists everything in the cwd.

try escaping the #

ls \#dir1

or or quoting the entire dir name:

ls '#dir1'


ls ./#dir1
share|improve this answer
Thanks a lot man. Me and my project mates we having some hard time with this – Anonymous Sep 4 '10 at 16:28

In the command ls #dir1, the shell interprets the hash character as the beginning of a comment -- so you get a listing of the current working directory.

share|improve this answer
Thanks a lot to you as-well steve – Anonymous Sep 4 '10 at 16:29

You must log in to answer this question.