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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.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命令参数_Linux_Bash_Shell_Ubuntu - Fatal编程技术网

将文件内容传递给linux命令参数

将文件内容传递给linux命令参数,linux,bash,shell,ubuntu,Linux,Bash,Shell,Ubuntu,我将随机生成的密码存储在/tmp/mysqlpwd.txt 我想将该文件的内容设置为自动安装中的密码。 我试过: sudo-debconf-set-selections这段代码已经是正确的(尽管它将内容放在stdin而不是参数上,这是debconf-set-selections所期望的) 您可以简单地测试这一点: echo "hello world" >file cat <<<"content follows: $(cat file)" 顺便说一下,当你的shell被

我将随机生成的密码存储在
/tmp/mysqlpwd.txt

我想将该文件的内容设置为自动安装中的密码。 我试过:


sudo-debconf-set-selections这段代码已经是正确的(尽管它将内容放在stdin而不是参数上,这是
debconf-set-selections
所期望的)

您可以简单地测试这一点:

echo "hello world" >file
cat <<<"content follows: $(cat file)"


顺便说一下,当你的shell被称为BASH时,你可能会考虑<代码> $(我想知道,也许在测试这一点时,你使用了与在这里使用的(正确的)双引号不同的引号。(这就是为什么一个被测试的重放器对于一个问题如此重要的部分))为什么<代码> $$?(那么我如何将文件的内容传递给
debconf set selections
?@sjsam,
$(cat file)
是低效的,因为它生成一个子进程,然后在该子进程中执行外部
/bin/cat
命令,从管道读取其输出——而
$(@pleasega,我不接受你的断言,它是真的。可能是你使用了错误的引号。@pleasega,…在你的命令中将
debconf set selections
替换为
cat
。它的输出中包含了什么?它是否表明shell按照要求执行了替换?
echo "hello world" >file
cat <<<"content follows: $(cat file)"
content follows: hello world