Search Results

Search: Posts Made By: AcerAspirant
3,095
Posted By methyl
Or ... read the output from the called script: ...
Or ... read the output from the called script:

#script1
./script2 | read reply
echo "Reply is: ${reply}"

#script2
echo "Working"
exit 0

./script1
Reply is: Working
3,095
Posted By cero
Simply source the called script, then all...
Simply source the called script, then all variables set there are available in the calling script too.
$ ./script1.sh
calling script 2
String: it works
Value: 1

$ cat script1.sh
echo calling...
3,095
Posted By Lem
May be with command substitution. Hint: ...
May be with command substitution.

Hint:

lem@biggy:/tmp$ cat file1
#!/bin/sh
false || echo "problem"
exit 0

lem@biggy:/tmp$ cat file2
#!/bin/sh
echo first
echo $(/tmp/file1)
echo last...
4,821
Posted By agama
To add some explanation to spacebar's post if...
To add some explanation to spacebar's post if it's not obvious...

To reference an array element you must enclose it in curly braces:


echo ${stuff[0]}

idx=0
echo ${stuff[$idx]}
4,821
Posted By spacebar
Try this: $ stuff[0]="foo"; grep -e...
Try this:
$ stuff[0]="foo"; grep -e "^\[\"Item\",\"${stuff[0]}\"," test.txt
["Item","foo",
6,830
Posted By Scrutinizer
The shell is field splitting the unquoted...
The shell is field splitting the unquoted variable reference, using $IFS. Try:
eval "$stuff"
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy