Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

yes 指令實戰:無限輸出指定字串,配合管線自動回應互動式提示

編輯:關於 Linux

指令說明

持續輸出指定字串(預設 y),直到收到中斷訊號。

語法

yes [--help] [--version] [字串]

參數

  • --help 顯示說明
  • --version 顯示版本

實例

yes "OK"
# 輸出:
OK
OK
OK
...
Ctrl+C 中斷

常見用法

yes | rm -i 大量檔案   # 自動回答 y 確認刪除
yes "accept" | 互動式安裝程式

結語

yes 非肯定語意,而是「無限產生字串」工具,配合管線自動化處理互動式確認提示,極大提升批次操作效率。

Copyright © Windows教程網 All Rights Reserved