Sponsored Content
Top Forums Shell Programming and Scripting How do I tell if a directory is empty? Post 302272540 by KenJackson on Tuesday 30th of December 2008 11:19:59 PM
Old 12-31-2008
OK, cfajohnson, your solution works. But it requires a whole additional separate function. The bigness wipes out any improvement in elegance or readability.

I kept looking at the stat command, thinking surely there must be an option that reports how many entries a directory has or something I could figure out to mean that. For example, this returns the number of blocks allocated, but that's not helpful for what I want at all.
Code:
stat -c%b /some/dir

 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. Shell Programming and Scripting

Empty Directory Check

Hi All, I have a requirement to check all the files in a directory and mail non empty files Files are in csv format , i need to skip header while checking pls help Thanks (12 Replies)
Discussion started by: gwrm
12 Replies

7. SCO

Deleting a directory that is not empty

I know someone will probably laugh at this question, I probably knew the answer many years ago when I was doing this full time but here goes..... I have a directory that has many files and sub-directories in it, RMDIR will not delete a directory that is not empty so what is the command to... (1 Reply)
Discussion started by: moondogi
1 Replies

8. Shell Programming and Scripting

Check whether a Directory is empty or not

1.pls tell me the command for checking whether a given directory is empty or not . 2. can i check what is the last copied item in a directory . and i yes , i want to move that last copied item in another directory . pls help me with shell code for these two tasks thanks (1 Reply)
Discussion started by: upvan111
1 Replies

9. Homework & Coursework Questions

Check whether a Directory is empty or not

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1.pls tell me the command for checking whether a given directory is empty or not . 2. can i check what is the... (1 Reply)
Discussion started by: upvan111
1 Replies

10. 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
TAU_TRACE_SENDMSG(3)					      TAU Instrumentation API					      TAU_TRACE_SENDMSG(3)

NAME
TAU_TRACE_SENDMSG - Traces a receive operation SYNOPSIS
C/C++: TAU_TRACE_SENDMSG(int tag, int source, int length); Fortran: TAU_TRACE_SENDMSG(integer tag, integer source, integer length); DESCRIPTION
TAU_TRACE_SENDMSG traces an inter-process message communication when a tagged message is sent to a destination process. NOTE: When TAU is configured to use MPI (-mpiinc=<dir> -mpilib=<dir>), the TAU_TRACE_SENDMSG and TAU_TRACE_SENDMSG macros are not required. The wrapper interposition library in $(TAU_MPI_LIBS) uses these macros internally for logging messages. EXAMPLE
C/C++ : if (pid == 0) { TAU_TRACE_SENDMSG(currCol, sender, ncols * sizeof(T)); MPI_Send(vctr2, ncols * sizeof(T), MPI_BYTE, sender, currCol, MPI_COMM_WORLD); } else { MPI_Recv(&ans, sizeof(T), MPI_BYTE, MPI_ANY_SOURCE, MPI_ANY_TAG,MPI_COMM_WORLD, &stat); MPI_Get_count(&stat, MPI_BYTE, &recvcount); TAU_TRACE_RECVMSG(stat.MPI_TAG, stat.MPI_SOURCE, recvcount); } Fortran : call TAU_TRACE_RECVMSG(tag, source, length) call TAU_TRACE_SENDMSG(tag, destination, length) SEE ALSO
TAU_TRACE_RECVMSG(3) 08/31/2005 TAU_TRACE_SENDMSG(3)
All times are GMT -4. The time now is 02:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy