fixxxer fixxxer - 1 year ago 87
Bash Question

How do I list one filename per output line in Linux?

I'm using

ls -a
command to get the file names in a directory, but the output is in a single line.

Like this:
. .. .bash_history .ssh updator_error_log.txt

Is there a built-in alternative to get filenames, each on a new line, like this:


Answer Source

Use man ls to see if your ls supports the -1 option (that the "one" digit, not a lowercase letter "L" - thanks @slashmais), e.g.



   Prints one entry per line of output.

GNU/Linux's ls does support it, so use:

ls -1a
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download