簡體   English   中英

AWS CLI 錯誤重定向在 bash 中不起作用

[英]AWS CLI error redirection is not working in bash

我正在按照 aws cli 運行以檢查 bash 腳本中的 db 實例。 我收到終端上發生錯誤 (DBInstanceNotFound) 的錯誤。 我想隱藏錯誤消息。

我已經重定向了 aws cli 輸出。 但它不起作用。

請在下面找到詳細信息。 幫我隱藏錯誤。

root@ip-10-192-21-59:~/abhi# aws rds describe-db-instances --db-instance-identifier test-db | grep -qi DBInstanceStatus  2>&1 >/dev/null

An error occurred (DBInstanceNotFound) when calling the DescribeDBInstances operation: DBInstance test-db not found.
root@ip-10-192-21-59:~/abhi#

將重定向應用於aws ,而不是grep

aws rds describe-db-instances --db-instance-identifier test-db 2>/dev/null | grep -qi DBInstanceStatus

您可以將重定向應用於管道中的任何命令(盡管如果您重定向stdout ,它將不會通過管道傳輸到下一個命令)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM