3

I'd like to show the contents of a folder without first changing into it. for example:

---- Documents
        |
        |
        L_ Essays

If I'm in Documents, how can I show the contents of Essays with a single command?

4
ls Essays/

works from within Documents. A tiny snippet of FreeBSD's ls man page:

 ls [ .... ] [file ...]

DESCRIPTION For each operand that names a file of a type other than directory, ls displays its name as well as any requested, associated information. For each operand that names a file of type directory, ls displays the names of files contained within that directory, as well as any requested, associated information.

  • Just add a slash? Really? – Moshe Feb 9 '12 at 15:44
  • 1
    just ls directory, the slash is not mandatory even, as, in your case, the file Essays is of type directory. – sr_ Feb 9 '12 at 15:46
  • Oh, I see, so the name of the target directory is what does it. – Moshe Feb 9 '12 at 15:48
  • 1
    @sr_: the slash is required if the directory is a symbolic (soft) link. – Hai Vu Feb 10 '12 at 5:59
  • @HaiVu: Thank you, I wasn't aware of this :) – sr_ Feb 10 '12 at 8:21
1

If you want to include the directory name in the listing, too:

find Essays/ -maxdepth 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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