check for file existance and generate exit code amd move to another directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting check for file existance and generate exit code amd move to another directory
# 1  
Old 06-26-2012
check for file existance and generate exit code amd move to another directory

Hi..
i have a file ABC_*.txt in source directory which will come evry 30 min and same file will be moved to working directory first time ...and will perform some operations then we archive ABC_*.txt ..this will run for 30 min to 45 min
from 2nd time onwards requirement is ...i need to check for the file in working directory ..if it is there then wait for till it is archived or else we need to move from source to working directory .

thanks,
Siva Santosh
# 2  
Old 06-26-2012
So... if the file exists, don't move it, but if it doesn't exist, do? Smilie
# 3  
Old 06-26-2012
after the job run there will be no file in working directory...so we need to check for the file in working directory before moving file from source ...
# 4  
Old 06-26-2012
Code:
while true
do
        set -- /path/to/folder/*
        [ -f "$1" ] || break
        sleep 1
done

This will replace your $1, $2, ... parameters.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check for files and move it to another directory - ksh

I'm trying to wirte ksh script for given requirement, but i unable to achive it. In dir1 directory I need to check for the files which suffixed with .csv or .txt, If there is no files, then i need to exit. If any files found I need to move the each file found to dir2 directory. I have to repeat... (4 Replies)
Discussion started by: Kayal
4 Replies

2. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

3. UNIX for Beginners Questions & Answers

Check output of command before outputing and keep exit code

so i have scripts that are piped and then run through one of the following mechanisms: cat myscript.sh | sh cat myscript.pl | perl what i want to do is, after either of the above commands are run, if the output from the command contains a certain string, i want it to avoid printing... (3 Replies)
Discussion started by: SkySmart
3 Replies

4. Shell Programming and Scripting

Csh/tcsh : Check the file existance and run the script

Hi, I've to wait until a file generated and once its generated, source another script in Linux terminal. Please help me as this is very very urgent. The code should be something like if ( -e "/abc/xyz/a.txt ) source aaa.csh else sleep This should be repeated till the if... (4 Replies)
Discussion started by: kumar_eee
4 Replies

5. Shell Programming and Scripting

how to check existance of multiple directories

Hi, I would like to check whether all the directories exists or not. I tried the below but it gives some error. below is the excerpt from my original script 24 #Check if the required directories are exists 25 dirExists() { 26 27 if 28 then 29 echo "required... (1 Reply)
Discussion started by: lookinginfo
1 Replies

6. Shell Programming and Scripting

Scripting to check the size of file and it's existance.

Hi, I am totaly new to create a script . Please help. I have file name retrived from SAP table into a internal table . Like :- /home/td_8d02_int_data_IPCL/ILLUSTRATIONS/CGM/l_pc_112138_01_0_01_00.cgm /home/td_8d02_int_data_IPC-L/ILLUSTRATIONS/CMP/l_pc_112138_01_0_01_00.cmp Objective... (1 Reply)
Discussion started by: amitkumar.b2
1 Replies

7. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

8. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

9. Shell Programming and Scripting

check the file existance

Hello, I have two files .. 1. inventory_i.txt 2. inventory_b.txt I want to check if these two files exists. If exists, then do the process, otherwise, quite... if ; then echo "exists" else echo " does not exists" fi The above logic is not working... It is always, displaying Does... (2 Replies)
Discussion started by: govindts
2 Replies

10. UNIX for Advanced & Expert Users

Move command return with exit code of 2

I have a script which loads data files into Oracle and then moves each file into a 'processed' directory when each file has finished loading. Last night I found that the script was failing on the mv statement (with a return code 2) and the following message, mv: cannot access... (1 Reply)
Discussion started by: handak9
1 Replies
Login or Register to Ask a Question