1

我正在尝试读取一个在灰壳中包含一个数字的文件。这样做的 bash 方式

ARG=`cat /tmp/tempfile`

不起作用,我知道 ARG 在这行代码之后没有任何内容。

4

1 回答 1

0

尝试用引号将其括起来以使其不会在第一个换行符处停止:

ARG="`cat /tmp/tempfile`"

或者

ARG="$(cat /tmp/tempfile)"

或者

read ARG  </tmp/tempfile #only 1st line will be read
于 2013-01-09T12:05:33.820 回答