To get a file in my cwd
in python I can do:
import os
cwd = os.getcwd()
filename = 'file.txt'
path = os.path.join(cwd, filename)
How would I do the same in a shell script?
To get a file in my cwd
in python I can do:
import os
cwd = os.getcwd()
filename = 'file.txt'
path = os.path.join(cwd, filename)
How would I do the same in a shell script?
The current working directory can be obtained in bash with the command pwd
.
Usually, the variable $PWD
contains the directory. So something like that should do:
full_path="${PWD}/foo.txt"
and by calling the pwd
command:
full_path="$(pwd)/foo.txt"