1

I want concatenate following:

current_dir=/home/akshay/UCS
source_dir=/lib/python2.7/lib-dynload/

I want to produce something like this:

/home/akshay/UCS/lib/python2.7/lib-dynload/

and then I will set above path as LD_LIBRARY_PATH.

How should I do this in bash script?

EDIT: the script so far:

current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 
echo ${current_dir} 
# Extract parent directory. 
parent_dir="$( dirname ${current_dir} )" 
echo ${parent_dir} 
source_dir=/lib/python2.7/lib-dynload/ 
echo "$parent_dir$source_dir"

only gives me $parent_dir back.

1 Answer 1

2

Simply

current_dir=/home/akshay/UCS
source_dir=/lib/python2.7/lib-dynload/
echo "$current_dir$source_dir"

And then export it

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$current_dir$source_dir
7
  • I am calculating current_dir in script. When I did above concatenation, it gives me only current_dir again.
    – akkidukes
    Apr 21, 2016 at 7:51
  • Can you elaborate what's the "calculating" you're doing?
    – P.-H. Lin
    Apr 21, 2016 at 7:53
  • current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" echo ${current_dir} # Extract parent directory. parent_dir="$( dirname ${current_dir} )" echo ${parent_dir} source_dir=/lib/python2.7/lib-dynload/ echo "$parent_dir$source_dir"
    – akkidukes
    Apr 21, 2016 at 7:54
  • You are not running this in one line right? the # will comment out the following command, try to separate it.
    – P.-H. Lin
    Apr 21, 2016 at 8:02
  • Please check edited post for actual script.
    – akkidukes
    Apr 21, 2016 at 8:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .