LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-07-2021, 08:09 PM   #1
iicapn
Member
 
Registered: Mar 2020
Posts: 35

Rep: Reputation: Disabled
Find latest version of a file


I'm trying to recover the latest version of a file: mylist.txt

I'm using rsnapshot for backups and I realized I lost this file for some reason, perhaps a month or two ago. I'd like to recover the latest version of the file but there are so many directories it's a bit daunting... I'm guessing the find command is the right tool, but unsure of how to use it with the right syntax to get the file with the latest [last modified?] date (or largest size?).

Maybe something like: find . -type f -name "myfile.txt" but not sure how to use it to get the latest one (or the largest one).

I read the man page for find and tried a few things to no avail... and googled but only found folks searching for latest files, not the latest version of a specific file... This box is running ubuntu 20.04.

Thank you all in advance! 🙏
 
Old 10-07-2021, 10:02 PM   #2
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,113
Blog Entries: 21

Rep: Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474Reputation: 3474
Have you tried using the grep command instead?

https://www.cyberciti.biz/faq/howto-...r-text-string/

or maybe the locate command

https://www.cyberciti.biz/faq/find-f...d-filesystems/

Here is find choices by date created

https://www.cyberciti.biz/faq/howto-...files-by-date/

Good luck.
 
Old 10-07-2021, 10:51 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
With rsnapshot, the file will be in the same directory it is in on the source…use find to list them…the latest one will be in the most recent snapshot in which it exists.
 
Old 10-08-2021, 12:05 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,129

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
To expand on that a little:
Only you know how your snapshot is setup, but you need to look in the most recent directory created - say /backups/daily.0/... (that's a zero). Then the /backups/daily.1/... which is the previous backup taken. Keep looking.
 
Old 10-08-2021, 12:20 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
find . -maxdepth 1 -mtime -1

Taken from this link: https://unix.stackexchange.com/quest...a-date-with-ls
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I have two version of GCC on the same linux system. How do i make the latest GCC version as default C++ compiler? seke Linux - General 9 08-06-2018 09:46 PM
Upgrading Apache 2.2.16 (package version) to the latest version 2.2.26 (compiled vers Renaud06 Debian 8 11-27-2013 06:59 PM
[SOLVED] The latest gcc/g++ version we can find on a linux distribution is 4.6.3 ? esgol Linux - Newbie 7 07-10-2012 07:14 AM
Yum is installing an old version of subversion -- how can I get the latest version? dhjdhj Linux - Newbie 6 06-18-2009 01:34 AM
where can I find the latest Linux deve version kevin05 Linux - General 8 02-24-2006 07:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration