Thanks, Steeve.  A brilliant solution I would never have thought
of....but which makes perfect sense now that I've seen it.
I spent some time today developing a regex to pre-test the dates, but
your solution is way more elegant. - Peter
-----Original Message-----From: Steeve McCauley <
[email protected]>To: Peter Buck <[email protected]>Cc: 
[email protected]: Re: suppress date() error messages?Date: Tue,
23 Apr 2019 08:38:37 -0500
redirect inside the $()

$ x=$(date --date="bad" +%s > /dev/null 2>&1)
$ echo $?
1


On Tue, Apr 23, 2019 at 8:05 AM Peter Buck <[email protected]> wrote:
> I have data that I know will contain a few bad dates. I want to
> 
> suppress the error messages.  Redirection isn't working.  Is there
> 
> anything I can do?
> 
> 
> 
> coreutils version 8.28-1ubuntu1 on Ubuntu 18.04.2 LTS
> 
> 
> 
> $ x=$(date --date="bad" +%s) > /dev/null 2>&1 
> 
> date: invalid date ‘bad’
> 


Reply via email to