BASH 脚本中的导出关键字

发布于 2024-10-02 03:55:26 字数 421 浏览 0 评论 0原文

我正在尝试在我的 Ubuntu 笔记本电脑上安装 PETSc。安装的第一步是在终端的 PETSc 目录的顶级目录中调用以下命令。

export PETSC_DIR=$PWD
./config/configure.py --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack=1 --download-mpich=1
make all test

问题 1:我是否应该实际输入“PWD”一词或顶级 PETSc 目录的地址?

问题2: 我想了解导出关键字的一般用途,特别是它在示例中的用途。我查看了一些关于导出关键字的参考文献,但所有这些参考文献都没有真正解释清楚。可能我一直在错误的地方寻找。

我从未编写过任何 shell 脚本,因此详细的答案将非常有帮助...非常感谢!

I am trying to install PETSc on my Ubuntu laptop. The first step of the installation is to invoke the following commands in the top level directory of the PETSc directory in the terminal.

export PETSC_DIR=$PWD
./config/configure.py --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack=1 --download-mpich=1
make all test

Question 1: Should I actually enter in the word 'PWD' or the address of the top level PETSc directory?

Question 2:
What I wanted to understand what the export keyword does in general and in particular what it does in the example. I have looked at some references on the export keyword and all of them did not really explain clearly. Probably I have been looking in the wrong places.

I have never done any shell scripting so a detailed answer would be very helpful...Thank you so much!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

金兰素衣 2024-10-09 03:55:26

export 所做的只是使环境变量的值可供子进程使用。

在这种情况下,他们假设您位于 PETSc 目录的顶级目录中。因此,使用 $PWD(打印工作目录)只是一个快捷方式,因此您不必键入路径。效果应该是相同的:

[jm72@localhost PETSc_1_1_1_1]$ pwd
/home/jm72/soft/PETSc_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ export PETSC_DIR=$PWD
[jm72@localhost PETSc_1_1_1_1]$ echo $PETSC_DIR
/home/jm72/soft/PETSc_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ export PETSC_DIR=/home/jm72/soft/PETSC_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ echo $PETSC_DIR
/home/jm72/soft/PETSC_1_1_1_1

All export does is make the value of an environment variable available to child processes.

In this case, they're assuming that you're in the top level directory of the PETSc directory. So using $PWD (print working directory) is just a shortcut so you don't have to type out the path. The effect should be identical:

[jm72@localhost PETSc_1_1_1_1]$ pwd
/home/jm72/soft/PETSc_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ export PETSC_DIR=$PWD
[jm72@localhost PETSc_1_1_1_1]$ echo $PETSC_DIR
/home/jm72/soft/PETSc_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ export PETSC_DIR=/home/jm72/soft/PETSC_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ echo $PETSC_DIR
/home/jm72/soft/PETSC_1_1_1_1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文