在变量中获取当前路径并使用它 [英] Getting current path in variable and using it

查看:44
本文介绍了在变量中获取当前路径并使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在变量中提取当前路径,并稍后在脚本中使用

I would like to extract the current path in a variable and use it later on in the script

类似的东西:

myvar = pwd

稍后:

cd myvar

但是我的bash技能多年来已经生锈了.

But my bash skills have rusted over the years.

我该怎么做呢?

推荐答案

myvar="$PWD"
cd "$myvar"

(如果路径中包含空格,则必须使用引号.)

(Quotes are necessary if your path contains whitespaces.)

这篇关于在变量中获取当前路径并使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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