1
I have multiple files in a directory they have numeric digits before their extensions. like below:
- SHG_PS_RG_10.tif
- ABC_MFCL_NHG_PS_RG_af_04.tif
- SHG_PS_RG_af_01.tif
- CBC_MFCL_NHG_PS_RG_af_03.tif
etc.. I want to sort them with the numeric (01,03,04 etc) like below:
- SHG_PS_RG_af_01.tif
- CBC_MFCL_NHG_PS_RG_af_03.tif
- ABC_MFCL_NHG_PS_RG_af_04.tif
- SHG_PS_RG_10.tif
How can I do this?
Thanks but i forgot to ask that i have spaces in the names of files like "SHG_PS RG_10.tif ". in this case what should i do ? how will we tell awk that in some files we have space and in other files we have underscore as field seperator. please propose a solution – Jamal – 2017-02-22T11:51:38.883
1I tried the command ls -1 af | tr -s ' ' '' | awk -F '' '{print $NF , $0}' | sort -n | cut -f2 -d' and it worked ! :) Thanks. – Jamal – 2017-02-22T12:10:59.460