我試圖了解如何禁用有關已棄用 ssl 的 mongodb 警告訊息。我確實在我的連接字串中添加了 --quiet 標志,但它似乎沒有幫助。
只是為了背景關系 - 我正在撰寫一個與資料庫互動的 bash 腳本,也許有一種方法可以將輸出定向到檔案或其他東西?這里是新手所以請原諒我:)
{"t":{"$date":"2022-05-12T10:58:02.347Z"},"s":"W", "c":"CONTROL", "id":12123, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"ssl","preferredName":"tls"}}
{"t":{"$date":"2022-05-12T10:58:02.347Z"},"s":"W", "c":"CONTROL", "id":12123, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"sslPEMKeyFile","preferredName":"tlsCertificateKeyFile"}}
{"t":{"$date":"2022-05-12T10:58:02.347Z"},"s":"W", "c":"CONTROL", "id":12123, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"sslCAFile","preferredName":"tlsCAFile"}}
uj5u.com熱心網友回復:
在您的 bash 中,任何命令輸出都可以被過濾、修改、發送到檔案,...
插圖:
#!/bin/bash
# Eliminate all output
/bin/ls -c1 /etc >/dev/null
# Filter the output, remove all files containing the word "host"
/bin/ls -c1 /etc | grep -v host
# Send to a file
/bin/ls -c1 /etc >output_file
# Send to a file and see the messages on your terminal
/bin/ls -c1 /etc | tee output_file
# Hide only the error messages
/bin/ls -c1 /etc 2>/dev/null
# Send all output AND errors to a file
/bin/ls -c1 /etc >output_file 2>output_file
# Same as above, other syntax
/bin/ls -c1 /etc >output_file 2>&1
# Modify the output. Here if the filename contains "host", replace it by "AAAA"
/bin/ls -c1 /etc | sed 's/host/AAAA/'
您可以根據命令輸出調整這些方法中的任何一種。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/474014.html
