Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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
Bash 文本输入,Shell脚本_Bash_Shell - Fatal编程技术网

Bash 文本输入,Shell脚本

Bash 文本输入,Shell脚本,bash,shell,Bash,Shell,我的朋友给我看了一个用shell脚本编写的程序,他在那里打开程序,它会问一个问题,他会键入答案,然后它就会关闭,但无论他键入什么,答案都会被传输到文本文档,有人能帮我吗我是新来的,我使用的是我使用的是bash,我使用的是Ubuntu13.10,如果你想要一个脚本来请求输入并将其写入文件,这是一个版本: #!/bin/bash read -p "What's your name? " input # prompt for name and store in var echo "Hello $

我的朋友给我看了一个用shell脚本编写的程序,他在那里打开程序,它会问一个问题,他会键入答案,然后它就会关闭,但无论他键入什么,答案都会被传输到文本文档,有人能帮我吗我是新来的,我使用的是我使用的是bash,我使用的是Ubuntu13.10,如果你想要一个脚本来请求输入并将其写入文件,这是一个版本:

#!/bin/bash

read -p "What's your name? " input   # prompt for name and store in var
echo "Hello $input!"                 # print greeting
echo $input >> myfile.out            # append to file
如果你想问别的问题,请澄清你的问题

#!/bin/bash

read -e -p "Which atom do you want me to investigate? " atom1
echo $atom1

read-e-p
允许用户退格

shell脚本的源代码是什么?我看不到脚本,所以我不确定问题出在哪里。通常堆栈溢出成员不想为您编写新代码。最好是上网搜索,先自己解决问题。然后,如果你陷入困境,你可以发布你所做的,我们会尽力帮助你解决它。