System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to move pertuclar date files in folder

Vinay GM
Occasional Contributor

How to move pertuclar date files in folder

Hello friends,

I have so many files in one folder. i want to move/delete some files which is created in perticular date, it is very difficult to move/delete one by one files. If i use *.* all files are moving which i dont want..

thanking you in advance...

Regards
Vinay
4 REPLIES
Robert Salter
Respected Contributor

Re: How to move pertuclar date files in folder

Hi Vinay,

I know there are probably easier ways to do what I think you want, but here's what popped into my head;

for i in $(ll|awk '$6 ~/mmm/ && $7 ~ /dd/ {print $9}')
do
rm $i
done

The "mmm" is for the month and the "dd" is for the day. And you could subsitute "mv" for the "rm".

Beers,

robert



Time to smoke and joke
Durvesh Mendhekar
Regular Advisor

Re: How to move pertuclar date files in folder

H,

ls -lrt > x

vi x

remove the name of the which u dont want to delete.

save and quit

cut -c59- x > x1

vi x1

:%s/^/rm"space"

save and quit

sh -x x1

Regards,
Durvesh
James R. Ferguson
Acclaimed Contributor

Re: How to move pertuclar date files in folder

Hi Vinay:

To find/remove/move files for a particular date, you could do (for example):

# touch -mt 200904010000.00 /tmp/ref1
# touch -mt 200904012359.59 /tmp/ref2
# find /path -xdev -type f -newer /tmp/ref1 -a ! -newer /tmp/ref2 -exec rm {} +

Regards!

...JRF...
chindi
Respected Contributor

Re: How to move pertuclar date files in folder

Hi Vinay,

Just use;


mv `ls -lrt|grep "June 19" |awk '{print $9}'`
/test
this will all files dated june 19 to folder /test..


Njy...