Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,如果inner.bash只是简单地echo a b c调用outer.bash,inner.bash如何将结果inner.bash捕获到用户的变量中outer.bash?这很简单,但我实际上不知道该怎么做。
inner.bash
echo a b c
outer.bash
内部.bash:
#! /bin/sh echo "a b c"
外部.bash:
#! /bin/sh x=`sh ./inner.bash` echo "result of inner is "$x
所以基本的事情是反引号`bla`给你返回bla的结果。
#!/bin/bash read -a text < <(inner.bash) echo "$text[1]"