bash - bash脚本中点的用法

标签 bash

以下代码片段第 8 行中的点是什么意思,来自 Mac OS X Mavericks 终端中的 /etc/profile 源。

  1 # System-wide .profile for sh(1)
  2 
  3 if [ -x /usr/libexec/path_helper ]; then
  4         eval `/usr/libexec/path_helper -s`
  5 fi
  6 
  7 if [ "${BASH-no}" != "no" ]; then
  8         [ -r /etc/bashrc ] && . /etc/bashrc
  9 fi

最佳答案

在 bash 中,. 是另一种拼写 source 的方式。所以这一行与此相同:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
        [ -r /etc/bashrc ] && source /etc/bashrc
fi

source 解释文件,就像内容包含在 source 命令的位置一样。执行它的不同之处在于它可以设置alias或定义function或变量。

关于bash - bash脚本中点的用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23085087/

相关文章:

git - 在 bash 脚本中检测当前目录

bash - 如何执行存储为带引号和星号的字符串的 bash 命令

linux - tail -f 搜索带有 * 匹配项和最新日期时间的文件

c - 在带有数学库的 Windows 上的 Ubuntu Bash 上出现 gcc 问题

linux - 如何使用awk打印文件中的第n列

bash - 将每个字符放在一个新行上

xml - sed 查找并替换 xml 文件中的值

Bash 脚本 - 在 case 结构或 if else 语句中不执行读取命令

bash - 在非登录 shell 中执行的 shebang 中执行 bash 脚本的正确语法是什么

python - 如何从 Jupyter Notebook 中的 Python 字符串执行 bash 脚本?