[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Best way to suppress the error message in $(< nonexistent_fi
From: |
Peng Yu |
Subject: |
[Help-bash] Best way to suppress the error message in $(< nonexistent_file) |
Date: |
Wed, 28 Nov 2018 06:01:31 -0600 |
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
- [Help-bash] Best way to suppress the error message in $(< nonexistent_file),
Peng Yu <=