LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-05-2018, 05:08 PM   #1
Artur860
LQ Newbie
 
Registered: Sep 2018
Posts: 3

Rep: Reputation: Disabled
Case


What command should I use to find out which files have been modified in the last 30 days, and what command should I use to copy these files to my home directory?
It's my second day working with Linux...
 
Old 09-05-2018, 05:15 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Look at the find command with the -mtime and -exec options.

By the way, what does the title of this thread "Case" have to do with your problem?
 
Old 09-05-2018, 05:56 PM   #3
Artur860
LQ Newbie
 
Registered: Sep 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
Message

Thanks hydrurga.
 
Old 09-05-2018, 05:59 PM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by Artur860 View Post
Thanks hydrurga.
Please come back and let us know what you come up with. I'm sure that folk on here will help refine your command for you if you just show us what you have produced so far.
 
Old 09-05-2018, 09:13 PM   #5
Artur860
LQ Newbie
 
Registered: Sep 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
?
find -type f -mtime -30
 
Old 09-06-2018, 02:50 AM   #6
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 900

Rep: Reputation: 290Reputation: 290Reputation: 290
Quote:
Originally Posted by Artur860 View Post
find -type f -mtime -30
Some remarks:
  • even if it's implicit in your example, you should get into the habit of specifying your search starting point (e.g.: find . -type f <some_other_options>)
  • there is no minus after -mtime option (-mtime 30)
  • you still need to use the -exec option for what you want to accomplish in fine with your files (you will need "{}" that represents your current file to be moved with mv)

PS: as stated by hydrurga, please write a more appropriate title for your thread.

Last edited by l0f4r0; 09-06-2018 at 02:54 AM.
 
1 members found this post helpful.
Old 09-06-2018, 04:39 AM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by l0f4r0 View Post
[*]there is no minus after -mtime option (-mtime 30)
There is a minus sign in front of 30.
-mtime -n: Modified LESS than n days ago
-mtime +n: Modified MORE than n days ago

Without '+' or '-' it is exactly 30 days IIRC.

jlinkels
 
2 members found this post helpful.
Old 09-06-2018, 04:52 AM   #8
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 900

Rep: Reputation: 290Reputation: 290Reputation: 290
Quote:
Originally Posted by jlinkels View Post
There is a minus sign in front of 30.
-mtime -n: Modified LESS than n days ago
-mtime +n: Modified MORE than n days ago
Without '+' or '-' it is exactly 30 days IIRC.
Okay, thanks for this clarification
 
Old 09-06-2018, 08:14 AM   #9
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
removed due to error in thinking.

Last edited by BW-userx; 09-06-2018 at 08:16 AM.
 
Old 09-06-2018, 06:15 PM   #10
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
I firmly suggest you not do it. Computer clocks often go wrong, it's a completely un-reliable thing to do to rely upon clocks. You could easily clobber files un-intentionally.
 
Old 09-06-2018, 08:12 PM   #11
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by X-LFS-2010 View Post
I firmly suggest you not do it. Computer clocks often go wrong, it's a completely un-reliable thing to do to rely upon clocks. You could easily clobber files un-intentionally.
That is a strange statement. When installed properly a computer syncs time with NTP. And even when it not does it, time is synced with the HW clock at every boot.
If this were true, any backup and restore scheme and any action depending on a file's timestamp should be unreliable.
The OS's file routines makes strong assumptions about the time being correct and procedures have been implemented at great length to keep the system clock correct. Like unprivileged users cannot change the time. NTP is not allowed to make time jumps while adjusting.
Can you justify this claim?

jlinkels

Last edited by jlinkels; 09-06-2018 at 08:14 PM.
 
  


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
[SOLVED] Bash: Checking for lower case and upper case letters in a string fatalerror0x00 Programming 1 12-09-2012 02:17 AM
Help with sed and awk to change L-case letters to U-case for specific lines in a file rootaccess Linux - General 12 05-21-2012 02:50 PM
mkisofs -iso-level 1 converts to lower case instead of upper case. stf92 Slackware 3 10-29-2010 12:32 AM
Copying files from case-sensitive Linux to case-insensitive Windows via CIFS? SlowCoder Linux - General 4 05-07-2008 07:03 PM
Why are all my upper case files being shown as lower case?? [Kernel 2.6.9-1.667 FC3] t3gah Fedora 4 03-11-2005 04:09 PM

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

All times are GMT -5. The time now is 10:46 PM.

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