misterjoff
misterjoff

Reputation: 13

Command to show last modified file, exluding directories

I am using ls -t | head -n1 (in the OS X bash shell) to return the last modified file in my working directory. In some cases, a subdirectory of the working file has the most recently modified file in it, so the command returns the name of that subdirectory. How do I write the command to exclude subdirectories?

Upvotes: 1

Views: 45

Answers (1)

JimR
JimR

Reputation: 513

ls -t * | head -1 works on mine

Upvotes: 1

Related Questions