Move files one at the time and wait until the previous file is handled


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Move files one at the time and wait until the previous file is handled
# 1  
Move files one at the time and wait until the previous file is handled

I'm a novice at unix and need it more and more to do my work.
I seem running into problems getting this script "attempt" to work:

I need to copy all files in a directory, which is containing 22000 files, into a directory one level up. There a tool monitors the content of the dir and processes all .aaa files if they arrive. Unfortunately, the tool is not quick and files may only be delivered at a slow pace

The files have to be copied one by one and when the previous file is not processed, the script should loop/sleep until the previously copied file is handled.


Here is what I tried

#!/bin/ksh
for file in `ls ~/tmp/d1/*.aaa
do
while [1]
do
if [! -f /~tmp/*.aaa]
then
echo "waiting"
sleep 1
else
echo "start processing file
break
fi
done
echo "Moving $file"
mv $file ~/tmp/
done


The script keeps moving files and don't wait until the previously copied file is handled and removed.
Anybody any idea what isn't correct ? I'm very gratefull for all advise !
# 2  
Code:
 
The files have to be copied one by one and when the previous file is not processed, the script should loop/sleep until the previously copied file is handled.

How do you know whether the file you copied hav processed/handled ?..

In your code your just checking for the presense of the file not whether it is handled or processed.
# 3  
That's very simple, a datastage map processes the file and then moves it to a archive. So if it's not there anymore, it's processed (except when bugs arise, but that's another story).
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #1004
Difficulty: Medium
Hopper College at Caltech University was named in honor of Grace Hopper in 2017.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to move files older than certain time?

If there are 100 files created in a directory /data/ today from 2:00 AM to 10:00 AM I need to move files older than 3:00 AM to a new directory /hold/ How to do that? Also, if I have to move files between 3:00 AM to 9:00 AM, how to achieve that (3 Replies)
Discussion started by: eskay
3 Replies

2. Shell Programming and Scripting

Process 2 lists at the same time and move files.

I have this while loop, that works but is quite slow to process though. I'm hopping there might be a faster/better way to find what I'm looking for. I have 2 lists of numbers, and want to only find files where a file name has both values present. each list has about 100 values. while... (10 Replies)
Discussion started by: whegra
10 Replies

3. Shell Programming and Scripting

[Solved] Help with shell Script ,wait for some files for some time??

Hi All, I have the requirement that ,i have to write a shell script that job has to wait for a 7 touch files created by another application for 4 hours, if i get all 7 touch files ,i have to send a mail that i jobs are completed, if if it is waiting for more than 4 hours i have to send a mail... (2 Replies)
Discussion started by: Pradeep Shetty
2 Replies

4. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. UNIX for Dummies Questions & Answers

How to move files based on filetype and time created?

Hi, I'm trying to improve my Unix skills and I'm wondering what is the best way to move some files based on filetype and attributes like time created? For instance, lets suppose I have a directory with many different files in it and I'd like to move all the jpgs that were created between May... (6 Replies)
Discussion started by: LuckyTommy
6 Replies

6. UNIX for Dummies Questions & Answers

move files between file systems with privileges, time stamp

Hi I have to move files between file systems but files in new file system must have the same attributes as in old one (privileges, time stamp etc). Which tool is best : - ufsdump / ufsrestore - tar - cpio - pax - dd - mv Or maybe there is sth else, you suggest to use. Thx for help (5 Replies)
Discussion started by: presul
5 Replies

7. UNIX for Dummies Questions & Answers

sample script to archive & move previous day syslog files

hi all. Please help me with archiving previous day syslog files. the files have no extension and have the format YYYY-MM-DD. I want to archive the file then move it to some other machine. thanks. (2 Replies)
Discussion started by: coolatt
2 Replies

8. Shell Programming and Scripting

Shell script to move certain files on scheduled time

Hi Friends, I want a shell script which will move certain .jar files from a specified location (say /publish/content) to (/publish/archive) on every saturday morning 6 am. One more thing to add is that before moving files it must check free space at (/publish/archive), if it is more than 60 %... (7 Replies)
Discussion started by: abhishek27
7 Replies

9. UNIX for Dummies Questions & Answers

Archiving and move files in the same time

Hi All, I have tried so many command but none work like i wanted. I would like archive which i assume it will move the files and archive it somewhere. for example: if i have a folder and files: /home/blah/test /home/blah/hello /home/blah/foo/bar i would like to archive folder... (6 Replies)
Discussion started by: c00kie88
6 Replies

10. Shell Programming and Scripting

Perl how to move pointer to previous line in a txt file?

I have a text file that has blocks of text. Each block starts with ### and ends with End_###. I wrote a perl script to search a string from line 2 (ignore any line starts with ###) of each block if matched, need to print that whole block. According to the input file in below, it will print... (5 Replies)
Discussion started by: tqlam
5 Replies

Featured Tech Videos