LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Changing .sh file dynamically (https://www.linuxquestions.org/questions/linux-newbie-8/changing-sh-file-dynamically-936363/)

Raakh5 03-25-2012 03:35 PM

Changing .sh file dynamically
 
Hello,

I have written a servlet that moves specific amounts of file from 0* folder to * folder (01 to 1) and process these files. I made a .sh file and inserted in cron task to run it after every one hour.

There are 12 folder on location of my server /home/savedCVs/ i.e.
01
02
03
04
05
06
1
2
3
4
5
6

My .sh file:
Code:

wget -q "http://www.myDomain.com/servlet/Variable?category=1&folderId=01&noOfFiles=212"
/*
category=1 is destination foldername
folderId=01 is source folder name
*/

Can I refine my .sh file that when 0* folder (say 01) became empty then change category=2 and folderId=02 and so forth and so on and when 06 become empty then stop ths shell process?

Thanks in anticipation

jhwilliams 03-26-2012 08:01 AM

You could use something based on find's -empty flag.

For example,

Code:

dir_number=1

if [ -z "$(find ${dir_number}/ -maxdepth 0 -type d -empty)" ]; then
    # The directory is empty
    # Do stuff here, then
    # Move to the next directory.
    $((dir_number++))
else
    # The directory has contents, do stuff here.
fi


Raakh5 04-01-2012 04:47 PM

Thanks a lot
Best regards


All times are GMT -5. The time now is 12:01 PM.