使用 Bash 将当前目录保存在变量中? [英] Save current directory in variable using Bash?
本文介绍了使用 Bash 将当前目录保存在变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要做的是找到当前工作目录并将其保存到一个变量中,以便我可以运行export PATH=$PATH:currentdir+somethingelse
.我不完全确定他们是否有一个默认包含 cwd 的变量.
What I'm trying to do is find the current working directory and save it into a variable, so that I can run export PATH=$PATH:currentdir+somethingelse
. I'm not entirely sure if they have a variable that contains cwd by default.
如何使用 Bash 将当前目录保存在变量中?
How do I save the current directory in variable using Bash?
推荐答案
这会将当前工作目录的绝对路径保存到变量 cwd
中:
This saves the absolute path of the current working directory to the variable cwd
:
cwd=$(pwd)
在你的情况下,你可以这样做:
In your case you can just do:
export PATH=$PATH:$(pwd)+somethingelse
这篇关于使用 Bash 将当前目录保存在变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文