2

Here is the output of my normal ls command:

f1  f10  f11  f12  f13  f14  f15  f16  f17  f18  f19  f2  f20  f3  f4  f5  f6  f7  f8  f9

So I have 20 files. I need them displayed as :

f1  f2 f3  f4  f5  f6  f7  f8  f9 f10  f11  f12  f13  f14  f15  f16  f17  f18  f19  f20  

Is there any single-line command to this other than writing a script? I am sure some of you must have faced this weird situation. Note: the above is just a sample. In the actual scenario I need a list of all the file names in proper sorted order. (ranging from f{0..10000})

0aslam0
  • 335

2 Answers2

5

fortunately! there is a single-line command

ls -lav

should do what you are looking for

lese
  • 2,726
2

With GNU ls, you can use:

ls -v

With POSIX tools chest:

ls | sort -nk1.2 | paste -sd ' ' -

If you are sure that all files in range existed, with shells have brace expansion:

echo f{1..20}

With zsh:

print -r -- f*(n)
cuonglm
  • 153,898