linux - How to handle change in the $PWD value in shell script? -


i have shell script executed tool. when executed tool value of $pwd set tool. when executed script manually value of $pwd current directory of script.

now i'm using $pwd environmental variable locate different file location in script.

but when execute manually file path changed , give unexpected results.

any suggestion how can handle change in value of $pwd while executing script manually or tool?

if need access directory script located, in bash can use

script_dir=$(readlink -f ${0%/*}) 

it takes relative path script ($0), cuts off script name , transforms full path.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -