Solved

moving files one at a time by oldest time to youngest  time

Posted on 2001-08-24
6
267 Views
Last Modified: 2010-04-21
I would like to move all the files in a directory, one at a time in 20 second internals with the files with the oldest date/time 1st and continue until finished. I know I can do the whole directory by
mv `ls /DIR/FILE*` /DIR2/

thanks  
0
Comment
Question by:petro2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:griessh
ID: 6423615
ls -tr gives you the files sorted by time in reverse order (oldest first), just check the man pages for 'ls'.

In ksh I would do something like this:

ls -tr | while read -r line
do
if [ -f $line ] ; then
<your move>
sleep 20
fi
done

The if ... just makes sure that it is a file and not a directory ...

======
Werner
0
 
LVL 11

Expert Comment

by:griessh
ID: 6423621
I guess we will see a few more universal suggestions soon.

======
Werner
0
 
LVL 6

Accepted Solution

by:
bira earned 300 total points
ID: 6423799
Hi


   My suggestion is

     for i in `ls -ltr|awk '{print $9}'`
   do
      a=`ls -l |grep $i|cut -c1-1`
      if [ "$a" != "d" ] ; then
            echo "Processing $i ..."
            cp $i /destination_dir
             sleep 20
      fi
    done
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:bira
ID: 6423801
0
 
LVL 6

Expert Comment

by:bira
ID: 6423803
I have places an cp ( copy command ) instead mv ( move )
for you to test.

  Regards
0
 

Author Comment

by:petro2
ID: 6423850
Does exactly what I need and exits correctly. thansk jq
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
aix tls version 6 557
cron job says it ran, no results 25 129
unix in java example 9 79
Writing a UNIX script menu allowing for multiple options. 5 93
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question