reading variables from other file
i have two shell script.
the nrec is declared once in first script as: echo -e "Number of Recursion step\nThe default value is 30" read nrec And the second one is #!/bin/bash #This script manages the Results mostly by #creating seperate files for each orbital #from the main o/p ab.dat for ((i=1; i<=9; i++)) do cnt=`expr $i \* $nrec` #echo "$cnt" head -$cnt RESULT/ab.dat|tail -$nrec>RESULT/$i.dat done is there any way to pass the variable nrec of first script to the 2nd one without reading it once again?? |
If the second script is launched from the first, you can use export to make the variable available to all the processes launched from the first script, e.g.
Code:
#!/bin/bash Instead, if the two scripts are launched separately, I think the only way is that the first script writes the value of nrec somewhere in a file and the second script waits for the file creation and then read the value of nrec (and eventually deletes the file). |
All times are GMT -5. The time now is 08:36 AM. |