Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-20-2014, 02:22 AM   #1
LQ Newbie
Registered: Oct 2013
Posts: 1

Rep: Reputation: Disabled
mv some particular date files

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 02:26 AM.
Old 02-20-2014, 04:18 AM   #2
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,575

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

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 04:19 AM.
Old 02-20-2014, 06:03 AM   #3
Senior Member
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,163
Blog Entries: 7

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
The other option find:

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, 09:08 AM   #4
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
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, 09:16 AM   #5
Senior Member
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Debian, Arch
Posts: 1,163
Blog Entries: 7

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
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.


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 03:02 AM
Deleting files by date Completely Clueless Linux - Newbie 2 11-05-2009 07:15 AM
Sort files in directories based on the files date... CharlieMike73 Programming 5 09-09-2009 11:04 PM
How do i remove files from date to date. Penn Linux - Server 5 10-21-2008 01:00 PM
filter files by date novaprime Linux - Software 1 05-31-2005 06:51 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:53 AM.

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