shell - Bash: Directory does not exist -
this question has answer here:
what little code snippet do? understand test command. question is: >&2
mean?
if test ! -d "$1" ; echo "directory not exist" >&2 ; exit 6 fi
thanks in advance!
it redirects stdout
stderr
.
when do:
echo "directory not exist"
the message goes standard output(1) . >&2
redirects standard error (2). useful when want capture stdout , stderr separately.
for example, if in script my_scr.sh
running as:
bash my_scr.sh > out_file 2> err_file
will ensure errors captured in err_file
, other output goes out_file
.
Comments
Post a Comment