I have a couple of files in a folder such as abc_2-01-2019.csv
, abc_2-02-2019.csv
, abc_2-03-2019.csv
, abc_2-04-2019.csv
, and I want to pick the latest file and send it over an email as an attachment on Linux VM. Can anybody help me out?
1 Answer
ls -Art | tail -n 1
where
-A do not include . and ..
-t sort by modification time
-r reverse sort
and tail -n 1
gets last entry
-
but that folder also contains other files than required CSVs. I want to choose latest csv with name abc_latest_date.csv Commented Feb 28, 2019 at 13:20
latest file
- according to creation date? modification date?