1

I understand commands such as

ls | sort -n

can do certain sorting.. but I would like Horizontal sorting just as it's being done via "ls" command.

Test in Empty folder:

 touch 1 2 12

with ls command

ls
1  12  2

What I want to see is:

1  2  12

Horizontally just like the "ls" command.

0

2 Answers 2

3

Using the command ls -v will give you the desired output:

1 2 12
2

For the BSD-inclined who do not have GNU coreutils installed and therefore can't use ls -v:

 $ printf '%s\n' * | sort -n | column
 1       2       12

The printf will generate a list of names, each on its own line. The sort will sort these numerically. The column utility will arrange these into columns, much like what ls does by default.

0