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?

  • 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... Commented Sep 5, 2010 at 4:05

2 Answers 2


# 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
  • Thanks a lot man. Me and my project mates we having some hard time with this
    – Anonymous
    Commented Sep 4, 2010 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.


You must log in to answer this question.