所有的macos命令:https://ss64.com/osx/
say
say 讓命令行說話 say是一個文本轉語音(TTS)的 mac 命令行工具,直接在后邊跟上一段話,電腦就會開始朗讀:
-> say "Hello 主人"
使用-f
參數選擇朗讀的文本文件,然后用-o
參數將朗讀結果存儲為某個音頻文件
-> say -f demo.txt -o demo.aiff
source 命令也叫點命令:
在當前shell執行命令。Read and execute commands from filename in the current shell environment and return the exit status of the last command.
⚠️不同的bash,同一個腳本,可能得到不同的結果。
~/自我練習 ⮀ bash bash-3.2$ echo $$ #顯示當前ip. 72768 bash-3.2$ source 123.sh bash: ls: command not found hello world 72768 bash-3.2$ exit exit
~/自我練習 ⮀ source 123.sh Applications cores opt Library data private Network dev sbin System etc tmp Users home usr Volumes installer.failurerequests var bin net hello world 72065
由此可見,ip不一樣。在不同的shell下,執行腳本得到不同結果。
再看這個例子:
~/自我練習 ⮀ echo $$ #當前shell是zsh 72065 (base) chentianwei@chentianweideiMac ⮀ ~/自我練習 ⮀ bash 123.sh #使用bash執行腳本,所以ip不一樣 Applications etc Library home hello world 72953
腳本頭#! /bin/bash 的意思:
表示使用bash開啟一個子交互, 完成腳本后退出這個bash.
#! /bin/bash
~/自我練習 ⮀ chmod +x 123.sh
~/自我練習 ⮀ ./123.sh #把123.sh變為可執行文件。然后用./123.sh執行這個腳本 Applications etc Library home hello world 73248 ~/自我練習 ⮀ echo $$ 72065