Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 使用sed将文本添加到bash中的行尾_Linux_Bash - Fatal编程技术网

Linux 使用sed将文本添加到bash中的行尾

Linux 使用sed将文本添加到bash中的行尾,linux,bash,Linux,Bash,我的脚本中有一个变量,名为: VAR=/opt/sbin/test 我想在行的末尾加上一个空格,比如“text”,然后以 /opt/sbin/test text 我认为您需要的命令是: VAR=/opt/sbin/test VAR="$VAR text" BLAH=$(${VAR}) 上面将$VAR设置为/opt/sbin/test text,然后BLAH=$(${VAR})将执行它。是否要在脚本中使用变量VAR运行/opt/sbin/text?yes@moran,并且仅用于此行无问

我的脚本中有一个变量,名为:

 VAR=/opt/sbin/test
我想在行的末尾加上一个空格,比如“text”,然后以

 /opt/sbin/test text 

我认为您需要的命令是:

VAR=/opt/sbin/test
VAR="$VAR text"
BLAH=$(${VAR})

上面将$VAR设置为/opt/sbin/test text,然后BLAH=$(${VAR})将执行它。

是否要在脚本中使用变量VAR运行/opt/sbin/text?yes@moran,并且仅用于此行无问题。我过去也做过类似的事情