About
Pricing
Community
Teams
Start Free Trial
Log in
royjayd
asked on
7/3/2012
finding the latest file
hi guys
when i do
$ls -ltr i get
-rwxrwxrwx 1 smwldvg steopsx 23429 Jul 3 13:36 EMPLOYEE_MASTER.rer
-rwxrwxrwx 1 smwldvg steopsx 0 Jul 3 08:18 EMPLOYEE_MASTER.rer
how can i write a command which will give me the latest file.
I want to see the file with the latest time 13:36.
any idea how i can do that?
thanks
Linux OS Dev
9
3
Last Comment
royjayd
8/22/2022 - Mon
omarfarid
7/3/2012
try
ls -ltr | head -2 | tail -1
ASKER CERTIFIED SOLUTION
farzanj
7/3/2012
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
omarfarid
7/3/2012
sorry, what I gave is not correct. It would work without -r option:
ls -lt | head -2 | tail -1
royjayd
7/3/2012
ASKER
ls -lrtc | tail -l
gives me the latest one modified file
ls -lrtc | tail -16
gives me the latest sixteen modified files
Am i correct ?
thanks
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
omarfarid
7/3/2012
yes
royjayd
7/3/2012
ASKER
alright, thanks
can you tell me what head does ?
ls -lt | head -2 | tail -1 -- what does it mean ?
SOLUTION
farzanj
7/3/2012
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
omarfarid
7/3/2012
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
royjayd
7/5/2012
ASKER
thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ls -ltr | head -2 | tail -1