Mac命令:say命令 source命令

 所有的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

 

原文地址:https://www.cnblogs.com/chentianwei/p/12360881.html