Sorts files in a directory based on a numeric index in the file name
I used a for loop in my script, like this….
for var in ipsec_packet*.txt; do
But I want them to start at 1 in this sort order to the largest available value (here 18)…
sort -n k14 but it didn’t help. Please suggest me some sort variants that can help me or any other bash/awk feature.
You can try
using sort with
the -V option for natural sorting of numbers in text:
for var in `ls ipsec_packet*.txt | sort -V`; do echo $var; done