I have a folder with 1-4 million files. Each file has this format:
trial_nubyb_$i_out.html
where $i is a number from 1 onwards
How do I get the largest 5 numbered files in the folder? I just need the 5 largest numbers, don't even need the filenames i.e. i just need largest 5 $i and no need trial_nubyb_$i_out.html, but the entire filenames are fine.
If I "ls -la | tail -5" this doesn't work because the system orders the filenames "alphabetically" and not from smallest to largest number, so the last 5 are actually:
trial_nubyb_999998_out.html
trial_nubyb_999999_out.html
trial_nubyb_99999_out.html
trial_nubyb_9999_out.html
trial_nubyb_999_out.html
I am using bash on Ubuntu.
A simple bash solution, but if it is too completed, PHP also welcome.