使用Bash将当前目录保存在变量中? [英] Save current directory in variable using Bash?

查看:119
本文介绍了使用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)

您可以这样做:

export PATH=$PATH:$(pwd)+somethingelse

这篇关于使用Bash将当前目录保存在变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆