Terminal Command to open most recently modified .Numbers file ???

Joined
Sep 13, 2006
Messages
3,570
Reaction score
470
Points
83
Location
Colorado
Your Mac's Specs
Mac's
Anyone know a Terminal Command to open the most recently modified .Numbers file in a particular directory?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
I can't help you right now but have you considered writing an applescript to do this? There may be something available if you look in the Numbers dictionary (I don't have Numbers so I can't look).

EDIT: Don't listen to myself of about ten minutes ago.

The ls command lists the files in a directory. According to the man page, the t switch will "sort by modification time" (man page). If you then used grep, you could probably limit the results to .Numbers files and have them print in order of last edited. So, something similar to:
Code:
ls -t | grep ".Numbers"
 
Joined
May 14, 2009
Messages
2,052
Reaction score
136
Points
63
Location
Near Whitehorse, Yukon
Your Mac's Specs
2012 MBP i7 2.7 GHz 15" Matte - 16 GB RAM - 120 GB Intel SSD - 500 GB DataDoubler Mac OS 10.9
I'm amazed, didn't think that I would manage it but I figured it out in about 30 minutes of trial and error.
And believe me, there were lots of errors :D

Code:
cd ~/Desktop; open "`ls -t | grep .Numbers | head -1`"

It's a bit picky about the file ending, the file extension needs to be visible in the finder and capitalization matters.
 
OP
RiDE
Joined
Sep 13, 2006
Messages
3,570
Reaction score
470
Points
83
Location
Colorado
Your Mac's Specs
Mac's
I'm amazed, didn't think that I would manage it but I figured it out in about 30 minutes of trial and error.
And believe me, there were lots of errors :D

Code:
cd ~/Desktop; open "`ls -t | grep .Numbers | head -1`"

It's a bit picky about the file ending, the file extension needs to be visible in the finder and capitalization matters.

That's perfect!!! the only tiny adjustment is Numbers.app extensions are lower-case (.numbers)

Thank you both very much!!!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top