Brian J. Murrell a écrit :
Is equally difficult?
Do you mean equally difficult as in impossible? Then I would say no,
it looks easier :-)
Or can I more easily play with FD duplication and redirection to
achieve that, even if it means adding a word at the end of things
I want on the real
empty_dir()
{
test x$(echo $1/*$2) = x$1'/*'$2
}
pk wrote:
This fails if the directory contains a file called *.
Yes. Unlike the ones below, empty_dir() above considers as empty a
directory that has a SINGLE element named '*'. Since I am not so
interested in files named '*', I think I
is_file()
{
[ -f $1 ] return
return 1
}
is_file /path/to/dir/* || echo empty
you don't need to check more than the first element
is_file()
{
[ -f $1 ]
}
is_file /path/to/dir/* || echo empty
test is redundant too
---
this could be another way to accomplish this
empty_dir() {
eval test \ $1/* \ == \ $1/* \;
}
(excluding invisible files...)
Marc Herbert wrote:
For purists, does this one works even better?
is_file3()
{
for f
do
[ -e $f -o -L $f ] return
done
return 1
}
You might also want to enable dotglob to catch hidden files...
On Fri, Dec 11, 2009 at 12:31:49PM +, pk wrote:
Marc Herbert wrote:
is_file3()
{
for f
do
[ -e $f -o -L $f ] return
done
return 1
}
You might also want to enable dotglob to catch hidden files...
empty=yes
for i in .?* *
do
kill builtin incorrectly thinks that -PGID is signal name even if the
signal name is set by -s or -n option.
Reproducer:
[rra...@dhcp-lab-170 ~]$ sleep 1d | sleep 2d | sleep 3d
[1] 5034
[rra...@dhcp-lab-170 ~]$ ps -j
PID PGID SID TTY TIME CMD
4863 4863 4863 pts/200:00:00
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
According to Roman Rakus on 12/11/2009 6:08 AM:
kill builtin incorrectly thinks that -PGID is signal name even if the
signal name is set by -s or -n option.
[rra...@dhcp-lab-170 ~]$ kill -s TERM -5032
bash: kill: 5032: invalid signal
On Fri, Dec 11, 2009 at 01:09:09PM +0100, Antonio Macchi wrote:
this could be another way to accomplish this
empty_dir() {
eval test \ $1/* \ == \ $1/* \;
}
(excluding invisible files...)
This one also has the problem of failing if the directory contains a
single file named '*'.
It
On Fri, 11 Dec 2009, Sven Mascheck wrote:
...
comp.unix.shell might match well here and could be entertaining -
IMHO worth to migrate; objections?
This has been discussed more than once in c.u.s; check the
archives.
--
Chris F.A. Johnson, webmaster
On Fri, 11 Dec 2009, Antonio Macchi wrote:
is_file()
{
[ -f $1 ] return
return 1
}
is_file /path/to/dir/* || echo empty
you don't need to check more than the first element
You may need to; it depends on the statement of the problem.
--
Chris F.A. Johnson,
Chris F.A. Johnson wrote:
This has been discussed more than once in c.u.s; check the
archives.
and that's why we better discuss it here now?
Sven Mascheck a écrit :
Chris F.A. Johnson wrote:
This has been discussed more than once in c.u.s; check the
archives.
and that's why we better discuss it here now?
I think Chris' message was more like: let's not discuss it at all and
just read the archives :-]
In case anyone is
On Fri, Dec 11, 2009 at 04:16:13PM +, Marc Herbert wrote:
In case anyone is interested my winner (so far) is:
exists()
{
[ -e $1 -o -L $1 ]
}
if exists foo/*; then
for f in foo/*; do
...
done
fi
What if there's a subdirectory or something and you'd like to skip it?
konsolebox wrote:
I hope the development team will also consider adding a way in bash to
declare global variables inside a function perhaps either with an
option in typeset or declare like -g (same as zsh) and/or a builtin
function like global as similar to local.
I thought variables in
On Fri, 11 Dec 2009 16:16:13 +
Marc Herbert marc.herb...@gmail.com wrote:
Sven Mascheck a écrit :
Chris F.A. Johnson wrote:
This has been discussed more than once in c.u.s; check the
archives.
and that's why we better discuss it here now?
I think Chris' message was more
2009-12-07, 22:22(+00), pk:
phani krishna jampala wrote:
bash is not capable of comparing of strings ( imean interms of lessthan or
greater than etc)
It is, if you use [[ ]]
a=abcd
b=bcde
if [[ $b $a ]]; then
echo $b is greater than $a
fi
[...]
Or the [ (aka test) builtin:
[ %b
17 matches
Mail list logo