Dear Sir,
I want to testwhether the Folder/Directory is
empty by usingjava
Can you please send me the source code which is
commented out to me as soon as you can.
Thank You
Gayan Denzil Jayasinghe
On Thu, Nov 19, 1998 at 01:47:33AM +, Julian Gilbey wrote:
However, a new question arises. Will this work in all cases:
rmdir $LDIR 2/dev/null grep -v $LDIR $LDSOCONF $tmpfile mv $tmpfile
$LDSOCONF || true
rm $tempfile # just in case the mv failed, or grep failed partly
Or
However, a new question arises. Will this work in all cases:
rmdir $LDIR 2/dev/null grep -v $LDIR $LDSOCONF $tmpfile mv $tmpfile
$LDSOCONF || true
rm $tempfile # just in case the mv failed, or grep failed partly
Or is there any trap door I miss?
What if you have a directory
Cylord [EMAIL PROTECTED] wrote:
if [ $(echo * ? .*) = * ? . .. ] ; then echo REALLY empty dir; fi
You also need .? or else you're subject to:
mkdir emptydir2; touch .*
--
Raul
On Mon, Nov 16, 1998 at 12:28:17AM -0600, [EMAIL PROTECTED] wrote:
[ `ls -1A $dir` ]
This returns '1' if the directory is empty and '0' otherwise. It is
not tricked by spaces or other unusual characters in file names.
It's not perfect, however:
mkdir emptydir3; cd emptydir3; touch ./-z
On Tue, Nov 17, 1998 at 11:04:28PM -0500, Raul Miller wrote:
Cylord [EMAIL PROTECTED] wrote:
if [ $(echo * ? .*) = * ? . .. ] ; then echo REALLY empty dir; fi
You also need .? or else you're subject to:
mkdir emptydir2; touch .*
With that echo command, 'touch .*' gives an echo result
Cylord wrote:
On Tue, Nov 17, 1998 at 03:05:08PM +0100, Richard Braakman wrote:
Chris Waters wrote:
if [ $(echo * .*) = * . .. ] ; then echo empty dir; fi
[but]
touch *
[fixed by]
if [ $(echo * ? .*) = * ? . .. ] ; then echo REALLY empty dir; fi
Good save! And a great demonstration of
On Tue, Nov 17, 1998 at 10:15:43AM +0100, Richard Braakman wrote:
Marcus Brinkmann wrote:
can someone give me a hint how I can efficient test if a certain directory
is empty in the postrm (shell script)?
If you only want to know if it's empty because you want to remove it,
then there's a
On Mon, Nov 16, 1998 at 12:28:17AM -0600, [EMAIL PROTECTED] wrote:
Marcus Brinkmann writes:
[ `ls -1 $dir` ]
This does not work. If the dir contains no file, it is [ ],
which returns 0, which is fine. If it contains more than one file, it is too
many arguments, therefore returning 1,
Marcus Brinkmann wrote:
can someone give me a hint how I can efficient test if a certain directory
is empty in the postrm (shell script)?
If you only want to know if it's empty because you want to remove it,
then there's a very simple solution:
rmdir directory 2/dev/null || true
The rmdir
Marcus == Marcus Brinkmann [EMAIL PROTECTED] writes:
Marcus can someone give me a hint how I can efficient test if a
Marcus certain directory is empty in the postrm (shell script)?
Here's what I did in the /etc/rc.boot/nethack script:
# Are there any lock-files to recover?
ls
Richard Braakman writes:
Marcus Brinkmann wrote:
can someone give me a hint how I can efficient test if a certain directory
is empty in the postrm (shell script)?
If you only want to know if it's empty because you want to remove it,
then there's a very simple solution:
rmdir
Sorry to provide such a late reply, I was off-list for a couple of
days. However, I've reviewed the answers provided so far, and I like
mine better. :-)
First, the easiest and most obvious way to check if a directory is empty
is to rm it. If that succeeds, the directory was empty. Of course,
Chris Waters wrote:
if [ $(echo * .*) = * . .. ] ; then echo empty dir; fi
Brilliant. :-)
It has only one flaw. *cough*
% mkdir emptydir; cd emptydir
% touch *
% if [ $(echo * .*) = * . .. ] ; then echo empty dir; fi
empty dir
*evil grin*
Richard
On Tue, Nov 17, 1998 at 03:05:08PM +0100, Richard Braakman wrote:
Chris Waters wrote:
if [ $(echo * .*) = * . .. ] ; then echo empty dir; fi
Brilliant. :-)
It has only one flaw. *cough*
% mkdir emptydir; cd emptydir
% touch *
% if [ $(echo * .*) = * . .. ] ; then echo empty dir; fi
Marcus Brinkmann writes:
I need something that returns an error code if the directory is empty but
does return 0 if it is non-empty.
[ `ls -1 $dir` ]
--
John Hasler
[EMAIL PROTECTED] (John Hasler)
Dancing Horse Hill
Elmwood, WI
Antti-Juhani Kaijanaho [EMAIL PROTECTED] wrote:
ls -1 | grep .\*
Actually, I'd recommend:
ls -A | grep -q .
Reasons:
(1) You don't care if the display is single or multi-column
Thus, the -1 option of ls is useless
(2) hidden files would still mean the directory is not empty
Marcus Brinkmann writes:
[ `ls -1 $dir` ]
This does not work. If the dir contains no file, it is [ ],
which returns 0, which is fine. If it contains more than one file, it is too
many arguments, therefore returning 1, which is also fine. But if it
contains one file, it returns 0, which is
Hi,
can someone give me a hint how I can efficient test if a certain directory
is empty in the postrm (shell script)?
Thank you,
Marcus
--
Rhubarb is no Egyptian god.Debian GNU/Linuxfinger brinkmd@
Marcus Brinkmann http://www.debian.orgmaster.debian.org
ls -1
(one)
--
Phil Humpherys [EMAIL PROTECTED] DriverSoft
Unix Systems Administrator Mobile: +1.801.725.3257
WWW/PGPkeys: http://www.spire.com/~humphery
Marcus Brinkmann [EMAIL PROTECTED] writes:
Hi,
can someone give me a hint how I can efficient test if a certain
On Sun, Nov 15, 1998 at 11:23:09AM -0700, [EMAIL PROTECTED] wrote:
ls -1
May be I am missing something, but this does only affect the formatting of
the output of ls.
I need something that returns an error code if the directory is empty but
does return 0 if it is non-empty.
Marcus Brinkmann
Marcus Brinkmann [EMAIL PROTECTED] writes:
On Sun, Nov 15, 1998 at 11:23:09AM -0700, [EMAIL PROTECTED] wrote:
ls -1
May be I am missing something, but this does only affect the formatting of
the output of ls.
-1 won't report . or .., but will return *nothing* of the
directory is empty.
*-Marcus Brinkmann [EMAIL PROTECTED]
|
| I need something that returns an error code if the directory is empty but
| does return 0 if it is non-empty.
I don't know how portable this is, but this seems to work for
me in bash:
test -d empty -a $(ls -l empty | wc -l) -eq 1
This returns 0 if empty
On Sun, 15 Nov 1998, Marcus Brinkmann wrote:
I need something that returns an error code if the directory is empty but
does return 0 if it is non-empty.
$ dirname=whatever_you_want_to_check
$ count=$(ls -A1 $dirname 2/dev/null | wc -l)
$ echo $count
I love shell... BTW, you need the
On Sun, Nov 15, 1998 at 12:07:39PM -0700, [EMAIL PROTECTED] wrote:
I don't know what you'd
use with shell if you needed an error code.
ls -1 | grep .\*
Antti-Juhani
--
Antti-Juhani Kaijanaho A7 [EMAIL PROTECTED] ** URL:http://www.iki.fi/gaia/
**
The FAQ is
25 matches
Mail list logo