Hi all,
I am writing a script to do the following:
1) Check if there are any new <csv> files (in abc directory) to process
2) If there is new file, then perform some operation on that file.
3) Move it to a different location(after step2 is successful)
4) Do further processing on the file
Problem is that there can be either one or more <csv> files that will be available in this directory.
All the above steps need to be performed on each new file.
Not sure how i could do this on multiple files
This is how i wrote the script...The script is not coming out of the loop when running this...
while true
do
for file in *.csv;
do
#Some operation
mv $file /xxx/yyy
#some operation
done
sleep 10
done
PLEASE HELP!!!!!
Thanks in Advance!!!
---------- Post updated at 05:28 PM ---------- Previous update was at 05:12 PM ----------
Hi Guys..I found this in the forum which i think is similar to what im trying to do...but Im not sure how i need to make the script exit when there are no files in that directory to process...Is there a way to do that?? PLEASE let me know!!!
while true
do
file_list=$( ls file1_* 2>/dev/null )
if [ -n "$file_list" ] ; then
for file_name in $file_list ; do
echo "Processing $file_name"
#run some command...
if [ $? -eq 0 ] ; then
mv $file_name .done/ # Assume .done dir
else
mv $file_name .error/ # Assume .error dir
fi
done
fi
sleep 2
done
THANKS in advance!!!!