2014-09-29 70 views
0

路径获取文件在我的蟒蛇cwd我可以这样做:如何加入shell脚本

import os 
cwd = os.getcwd() 

filename = 'file.txt' 
path = os.path.join(cwd, filename) 

我怎么会做相同的shell脚本?

+0

怎么也[让你的工作目录(http://stackoverflow.com/questions/8635456/how尚北道任您得到最电流的工作目录,在-的bash) – CoryKramer 2014-09-29 21:00:18

回答

2

当前工作目录可以在bash中用命令pwd获得。
通常,变量$PWD包含该目录。所以,这样的事情应该做的:

full_path="${PWD}/foo.txt" 

,并通过调用pwd命令:

full_path="$(pwd)/foo.txt"