List all files created today exclude last one

Hi, ALL
thanks in advance,
i listed all files using this command

ls -ltr  $(date   +%Y%m%d)*.xml

but i would like to exclude the last one created ;
Best regard
MEROUAN

Try:

ls -lt  $(date   +%Y%m%d)*.xml | awk 'NR>1'
1 Like

hideous, but it works

ls -ltr $(date   +%Y%m%d)*.xml  | head -$(( $(ls -ltr $(date   +%Y%m%d)*.xml | wc -l) - 1 ))

And Bartus' solution above is infinitely better, reminding me once again that I must go through a good book on awk :wink:

2 Likes

Add ... | sed '$d' to your command.

If the desc order doesn't matter:

ls -lt "$(date +%Y%m%d)"*.xml | tail -n +1
1 Like

yes it works i use Skrynesaver solution .
THANKS ALL FOR TIME