当我跑步
echo "invalid crt" | openssl x509 -noout -modulus | openssl md5 &>> error.log
这下面显示错误
unable to load certificate 139903857870496:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE
和“(stdin)= d41d8cd98f00b204e9800998ecf8427e”的内容在error.log
我想保存错误的stdin(如何将terminal错误文本保存到error.log中)
我怎样才能做到这一点 ?
当你这样做
echo "invalid crt" | openssl x509 -noout -modulus | openssl md5 &>> error.log
只有第二个openssl命令的stderr被写入error.log。 用这个:
echo "invalid crt" | (openssl x509 -noout -modulus | openssl md5) &>> error.log
这样两个openssl进程都在一个子shell中运行,并且子shell的stderr与stdout一起被redirect到error.log。
使用cmd &> file.log :
$ blahblah &> /tmp/blah.log $ echo $? 127 $ cat /tmp/blah.log bash: blahblah: command not found
要追加,使用cmd >>file.log 2>&1
$ wrongcmd >>/tmp/blah.log 2>&1 $ cat /tmp/blah.log bash: blahblah: command not found bash: wrongcmd: command not found