i have a bunch of files from log1 to log164, how can i create a file like below ordering... please help me...
- log1.gz
- log10.gz
- log100.gz
- log101.gz
- log102.gz
- log103.gz
- log104.gz
- log105.gz
- log106.gz ...etc
i have a bunch of files from log1 to log164, how can i create a file like below ordering... please help me...
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'
ls > listfile
? – G-Man Says 'Reinstate Monica' Nov 01 '16 at 07:38