简体   繁体   中英

Call script from script

I have a bash script A from which I'd like to call bash script B. I'd like to declare a number of paths in B, call B from A and fetch the paths..is it possible? If so, how do I achieve it? The scripts are located in the same folder.

Maybe it would be easier to just source the scriptB from scriptA?

. ./scriptB

This way they are run in same shell and all variables are shared.

There are several ways of doing this. One way is to echo the paths in scriptB and set a variable in scriptA to capture the output:

In scriptA

paths=$(./scriptB)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM