BASH - 提示粘贴多行输入保存到文件
BASH - Prompt paste multiple lines of input save to file
我有一个脚本要求我的用户输入一些信息。名称、ID、位置等
他们是否可以将多行数据粘贴到提示输入中并将其保存到文件中?
echo -e "Please enter the details:"
read data
# Do something... and save to file..
他们将粘贴类似于以下内容的数据:
67jhub7uy86b8tib8,North
485734957934fsdfs,East
7676bh7h87g87bibi,East
89798kfhg8r9t8494,South
98onoulj5005555tr,West
可能有1行,可能有50行..
有什么想法吗?
你可以使用这个read
:
read -rp 'Please enter the details: ' -d $'' data
输入多行数据后在终端上按 ctrl-D
。
使用
检查data
变量的内容
declare -p data
我有一个脚本要求我的用户输入一些信息。名称、ID、位置等
他们是否可以将多行数据粘贴到提示输入中并将其保存到文件中?
echo -e "Please enter the details:"
read data
# Do something... and save to file..
他们将粘贴类似于以下内容的数据:
67jhub7uy86b8tib8,North
485734957934fsdfs,East
7676bh7h87g87bibi,East
89798kfhg8r9t8494,South
98onoulj5005555tr,West
可能有1行,可能有50行..
有什么想法吗?
你可以使用这个read
:
read -rp 'Please enter the details: ' -d $'' data
输入多行数据后在终端上按 ctrl-D
。
使用
检查data
变量的内容
declare -p data