Peng Yu
2018-11-28 12:01:31 UTC
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>&-
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
Regards,
Peng