fixxxer fixxxer - 2 months ago 7
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:

.
..
.bash_history
.ssh
updator_error_log.txt

Answer

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.

http://docs.oracle.com/cd/E19082-01/819-2239/6n4hsf6oc/index.html

...

-1

   Prints one entry per line of output.

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

ls -1a
Comments