[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2001-08-24
6
Medium Priority
?
272 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 1200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

649 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