help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Best way to suppress the error message in $(< nonexisten


From: Pierre Gaston
Subject: Re: [Help-bash] Best way to suppress the error message in $(< nonexistent_file)
Date: Wed, 28 Nov 2018 14:04:39 +0200

On Wed, Nov 28, 2018 at 2:01 PM Peng Yu <address@hidden> wrote:

> Hi,
>
> I only find the exec way to suppress the error message of $(<
> nonexistent_file). But the syntax doesn't look very nice. Is there a
> better way to do so? Thanks.
>
> x=$(< nonexistent_file) 2> /dev/null # This doesn't work.
>
> exec 3>&2 2>&- # This works
> x=$(< nonexistent_file)
> exec 2>&3 3>&-
>
> --
> Regards,
> Peng
>
>
{ x=$( <doesnotexist) ;} 2>&-


reply via email to

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