2

Please explain the meaning of this statement

. ./ab_project_setup.ksh $(pwd)
Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
Srihari
  • 2,509
  • 5
  • 30
  • 34

2 Answers2

2

Adding to Alberto's answer:

Here is a small demo:

$ cat a.sh        # the script a.sh just exports a variable foo
export foo="$1"   # with it's value set to first command line argument.
$ echo $foo       # currently variable foo is not set.

$ . ./a.sh $(pwd) # source the script passing it pwd as argument.
$ echo $foo       # variable foo is now set.
/home/codaddict
$ pwd             # the present working directory.
/home/codaddict
Community
  • 1
  • 1
codaddict
  • 445,704
  • 82
  • 492
  • 529
  • `. ./a.sh $(pwd)` # source the script passing it the output of `pwd` as argument (not the text 'pwd') – johnsyweb Nov 12 '10 at 10:09
  • $cat srihari.sh export srikanth="$1" $ksh -x srihari.sh $(pwd) + export srikanth=/home/examples/workbook1/srihari2010 $echo $srikanth --nothing displayed-- $. ./srihari.sh $(pwd) $echo $srikanth /home/examples/workbook1/srihari2010 $pwd /home/examples/workbook1/srihari2010 What is the difference? – Srihari Nov 12 '10 at 10:23
1
.

means source what is following

./ab_project_setup.ksh

the name of the file you are sourcing

$(pwd)

expands to the current working directory and is passed as argument to the script.

Alberto Zaccagni
  • 30,779
  • 11
  • 72
  • 106
  • thanks Alberto for your answer from your explanation i understood that $(pwd) is sent as an argument.How will we know whether the script expects argument and also why here in . ./script.ksh $(pwd) statement two dots are used?pls answer. – Srihari Nov 12 '10 at 09:55
  • @srihari: to know if the script uses any parameter just open it and look inside, you should see a `$1` used; the first dot is to source, the second to specify that you want to use a file named `script.ksh` in the current directory. – Alberto Zaccagni Nov 12 '10 at 11:05