LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-25-2012, 03:35 PM   #1
Raakh5
Member
 
Registered: Mar 2012
Posts: 174

Rep: Reputation: Disabled
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
 
Old 03-26-2012, 08:01 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
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

Last edited by jhwilliams; 03-26-2012 at 08:04 AM.
 
1 members found this post helpful.
Old 04-01-2012, 04:47 PM   #3
Raakh5
Member
 
Registered: Mar 2012
Posts: 174

Original Poster
Rep: Reputation: Disabled
Thanks a lot
Best regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Port number is changing dynamically for each Authentication request in RHEL ghvijayakumar Linux - Newbie 4 01-13-2012 05:14 AM
[SOLVED] Changing the NIC for a guest dynamically on Cent OS 6.0 ThomasRonshof Linux - Virtualization and Cloud 17 12-14-2011 05:29 AM
dynamically changing delay pool acl squid.conf lasantha Linux - Server 1 05-05-2009 04:39 AM
Changing a table contents dynamically based on select box rose_bud4201 Programming 4 01-13-2005 10:48 AM
changing samba configuration dynamically ramu_ak Linux - Networking 1 12-28-2003 02:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration