Waiting till the directory becomes empty


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Waiting till the directory becomes empty
# 8  
Old 10-21-2010
it is not working in bash.

im using tcsh. Can you please suggest the right syntax?
# 9  
Old 10-21-2010
Hi, what is not working and are you using bash or tcsh?
# 10  
Old 10-21-2010
I am trying your code:

until [ "$(echo "$DIR/"*)" = "$DIR/*" ]
do
sleep 2
done

But it says Illegal variable Name

I am using tcsh.
# 11  
Old 10-21-2010
It is POSIX compliant shell code. It will not work with tcsh. You can put this at the first line of your script:
Code:
#!/bin/bash

or this: #!/bin/sh or #!/bin/ksh (or #!/usr/xpg4/bin/sh if you are on Solaris).
# 12  
Old 10-21-2010
It is my project need that I should run the script in tcsh only.

So I need the tcsh compliant code only.
# 13  
Old 10-21-2010
Quote:
Originally Posted by AB10
It is my project need that I should run the script in tcsh only.

So I need the tcsh compliant code only.
you can try this Smilie

Code:
#!/bin/tcsh
 while (1)
      if (`find yourpath/|wc -l` > 1) then
         echo "Not Processing -> [ waiting for empty ]\n File list ..\n"
         ls -l yourpath/|grep -v total
         echo "" ; sleep 2
      else
         echo "Processing now ..\nProcess is now complete";
         break;
      endif
  end

# 14  
Old 10-21-2010
rm -rf <your directory>
wait
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Perl - How to empty a directory?

Hi Guys, i'm writing a perl script which whenever runs, should empty 3 pre-decided directories as first step and then the script has the logic to parse some other directories and copy the files inside those directories into these 3 directories. I've the logic already developed, just need to... (2 Replies)
Discussion started by: jhamaks
2 Replies

2. Shell Programming and Scripting

check empty directory !!!

I need to check if a directory is empty using an if condition in the pseudocode below if ; then else although i looked at a few forums on this topic, I left feeling a little unclear and i could not use the command successfully what can i substitute in the if conditon above,... (2 Replies)
Discussion started by: allah_waris45
2 Replies

3. Shell Programming and Scripting

check whether the directory is empty or not

I have the list of users in user.log, under each user folder there is sub1 folder is there. i want to check whether sub1 is empty or not, if it is empty i have to skip that user user folder and iterate next user folders. i have the sample code,its not giving not proper results. while read line... (8 Replies)
Discussion started by: KiranKumarKarre
8 Replies

4. Shell Programming and Scripting

remove empty directory

Hi, I need to delete an empty directory in a temp directory except "dir5" (keep everything that is not empty). Plese advise. Here is an example of my directory. /dir/temp/ dir1 - delete if this is empty dir2 - delete if this is empty dir3 - delete if this is empty dir4 - delete if this... (7 Replies)
Discussion started by: sirrtuan
7 Replies

5. Shell Programming and Scripting

How do I tell if a directory is empty?

To see if a directory is has anything in it, I do this: if ; then # do something fi But surely there is a more easy-to-read and elegant way. Isn't there? (6 Replies)
Discussion started by: KenJackson
6 Replies

6. Shell Programming and Scripting

How to print lines till till a pattern is matched in loop

Dear All I have a file like this 112534554 446538656 444695656 225696966 226569744 228787874 113536566 443533535 222564552 115464656 225445345 225533234 I want to cut the file into different parts where the first two columns are '11' . The first two columns will be either... (3 Replies)
Discussion started by: anoopvraj
3 Replies

7. Shell Programming and Scripting

How to empty all files in a directory

Hi all, Can you tell me how to empty all files in a directory with a "find" command? It does not seem to work the way I try it: # ls -l *.dat -rw-r--r-- 1 root root 7 Jul 20 20:51 la2.dat -rw-r--r-- 1 root root 4 Jul 20 20:51 la.dat # find... (9 Replies)
Discussion started by: majormark
9 Replies

8. Shell Programming and Scripting

Setting the right directory as non-empty

Hi guys, I've been trying to get this part of my script to work for ages and now it's getting me annoyed!! So i thought a fresh group of eyes could see where i'm going wrong! The idea is getting a directory and all its files moved to a temp folder, but similar to the rm -ir command where it... (0 Replies)
Discussion started by: olimiles
0 Replies

9. Shell Programming and Scripting

need to read a file and keep waiting till it satisfies some condition

In my script i am writing to a counter file the no of processes i had started, that is each time i start a process, i will increment the content of counter file and also when the process ends i will decrement the content of the file. after this i do some other activities, by now i want to... (1 Reply)
Discussion started by: senthilk615
1 Replies

10. UNIX for Dummies Questions & Answers

rmdir a non-empty directory.

hi, i understand that rmdir will only remove direcotry when it is empty but are there options which will also remove non-empty directories? i went to man rmdir but only find the option -p? i am on solaris. thanks (2 Replies)
Discussion started by: yls177
2 Replies
Login or Register to Ask a Question