0

i have a bunch of files from log1 to log164, how can i create a file like below ordering... please help me...

  1. log1.gz
  2. log10.gz
  3. log100.gz
  4. log101.gz
  5. log102.gz
  6. log103.gz
  7. log104.gz
  8. log105.gz
  9. log106.gz ...etc

1 Answers1

1

You can get an ordered list by simply using ls -v. But the next formatting part is a bit trickier. If you need an enumerated list (I am assuming the formating is same as in your question) you can use awk. Use pipe to feed the ls -v output to awk.

ls -v | awk '{print NR ".",$0}'

If you don't need the enumeration, then it can be done without awk. In the output of ls -v replace the spaces by a new line character.

ls -v | tr ' ' '\n'

trishnendu
  • 314
  • 1
  • 9