【发布时间】:2015-11-06 23:18:18
【问题描述】:
我正在编写一个小脚本,我遇到的部分问题是找到要使用的正确文件。该脚本设置工作目录并提示用户输入文件名,如下所示:
#!/bin/bash
#Now to set the directory for the user files, which will be used to execute the$
#cd "$(M:/ "$0")" // to be used on campus machines only
#using it at home will break the script due to not being on the M:/ drive
echo We are currently working from the M directory.
echo Please enter the bash script name, which should be formatting as username.
我如何读取用户的输入(甚至允许用户输入一些内容然后读取),然后这些输入将用于打开同一目录中的文件?
我会使用变量并将用户的输入分配给它还是其他的东西?
谢谢!
【问题讨论】:
-
看看:
help -m read | less -
谢谢@Cyrus,您介意解释一下每个部分的含义,以便我能正确理解吗?
-
哎呀,我是个白痴。谢谢。