Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mv script

Status
Not open for further replies.

hammam02

IS-IT--Management
Mar 23, 2009
27
EG
i have aix6.1

i write script to move file from directory to another
but the source is file name random by time

how can determin the source to move

my script is

xx='ls -ltr |awk '(print $9}''
but the value is all of files in the directory

i need to determin the newer file created
 
If you are running this command once every day then the following command will do the job!

Code:
To list all files in the current directory that have been changed during the current 24-hour period, enter: 
find . -ctime 1 -print | xargs -t -I {} mv {} /destination_dir

If you intend to run the command more than once then you can use the following:

Code:
find . -newer temp_file -print | xargs -t -I {} mv {} /destination_dir
rm temp_file
touch temp_file

You just need to create the temp_file once before running the above scrip or otherwise you will get an error as the file won't be available by then. The rm command is only because i haven't tested the command above and maybe the touch over temp_file will only modify the last modified time!

Regards,
Khalid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top