LinuxQuestions.org
Help answer threads with 0 replies.
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 02-20-2014, 01:22 AM   #1
ajin4647
LQ Newbie
 
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
mv some particular date files


hi,
This is ajin, i am using rhel6. i try to some particular date files move from one directory to another directory via cmd prompt but i cant move it. so pls any one help how can i do? like i am using cmds

root@localhost testimage]# ls -ltr
root@localhost testimage]# ls -ltr | grep "Jul 14" >ajin
[root@localhost testimage]# cat ajin
-rwxr-xr-x. 1 root root 21647 Jul 14 2013 851586_582402758437370_1862901244_n.png
-rwxr-xr-x. 1 root root 5562 Jul 14 2013 851580_201013666715234_1869448187_n.png
-rwxr-xr-x. 1 root root 24670 Jul 14 2013 851584_213405905475301_992858851_n (1).png
-rwxr-xr-x. 1 root root 7829 Jul 14 2013 851584_213405905475301_992858851_n.png

and now i do move above files only into another directory ( like /root/Desktop/todaytest) pls tell me what i do the next step?

Last edited by ajin4647; 02-20-2014 at 01:26 AM.
 
Old 02-20-2014, 03:18 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,380

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
One way is to make use of xargs

Code:
ls -ltr | grep "Jul 14" | awk {'print $9'} | xargs -I {} mv {} /root/Desktop/todaytest
However, I would strongly suggest that you use "cp" to make copies rather than "mv" move files while you're testing

Last edited by TenTenths; 02-20-2014 at 03:19 AM.
 
Old 02-20-2014, 05:03 AM   #3
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,159
Blog Entries: 7

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
The other option find:

Code:
find . -newermt "Jul 14 2013" -and \! -newermt "Jul 14 2013" -exec mv {} /root/Desktop/todaytest \;
The first -newermt means find files modified after the specified date.
The second, \! -newermt means find files not newer than that date.

So this in effect finds files modified only on that date. You can change the dates to specify a range of dates.

If you're looking to find files modified in the past x days, there are simpler options, like -m.

Check out the find(1) man page for more on these options.
 
Old 02-20-2014, 08:08 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,688

Rep: Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259
Since you didn't show the error message you are/were getting, I'm going to guess it the poor choice of characters in the file name '2013 851584_213405905475301_992858851_n (1).png'.

The three bad characters are space and the parenthises. Both will break normal shell operations - especially if you tried to move them all with one command. The space will cause a "file not found" error, the parenthese will likely break the entire command line as the shell must interpret the contents first... and usually the program "1" does not exist - thus aborting the command.

If you absolutely, positivily MUST have those characters in the name, then you need to put quotes around the file name (apostrophe quotes, not double quotes, as double quotes allows for substitutions and the apostrophe quotes do not).
 
Old 02-20-2014, 08:16 AM   #5
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,159
Blog Entries: 7

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
I didn't see any mention of an error, I just took it as the OP had no clue of going about doing what he wanted. BTW tested it, and the find version will move the files with the bad characters, just FYI. And I'd be willing to bet the bad choice of characters comes from Firefox or some other program that renamed a file because the name already existed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Application to eliminate doubles in files and rename changed files with date? S. Chapelin Linux - Software 6 01-16-2011 02:02 AM
Deleting files by date Completely Clueless Linux - Newbie 2 11-05-2009 06:15 AM
Sort files in directories based on the files date... CharlieMike73 Programming 5 09-09-2009 10:04 PM
How do i remove files from date to date. Penn Linux - Server 5 10-21-2008 12:00 PM
filter files by date novaprime Linux - Software 1 05-31-2005 05:51 AM


All times are GMT -5. The time now is 08:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration