bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash conditional expressions


From: Ilkka Virta
Subject: Re: bash conditional expressions
Date: Wed, 17 Nov 2021 14:06:02 +0200

On Wed, Nov 17, 2021 at 1:33 PM Andreas Schwab <schwab@linux-m68k.org>
wrote:

> On Nov 17 2021, Michael J. Baars wrote:
>
> > When -N stands for NEW, and touch (-am) gives you a new file
>
> It doesn't.  The file hasn't been modified after it was last read.
>

touch creates the given file if it doesn't previously exist. Immediately
afterwards,
it could be called "new" in the usual English meaning, and would be new in
the
sense that nothing was done to it after it was created. But:

$ echo $BASH_VERSION
5.1.8(3)-maint
$ rm foo.txt
$ ls -l foo.txt
ls: cannot access 'foo.txt': No such file or directory
$ touch -am foo.txt
$ if test -N foo.txt; then echo is new; else echo is NOT new; fi
is NOT new

Of course "new" is not an exact concept, it could be defined e.g. to
compare the
file timestamps with the current time.

Anyway, the documentation doesn't seem to say 'test -N' tests if the file
is "new".


reply via email to

[Prev in Thread] Current Thread [Next in Thread]