Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建一个脚本,该脚本将提示用户输入文件名,请求用户输入四个人的姓名,然后将名称排序到指定的文件中。
You can use this code:
#!/bin/bash read -p "Enter filename: " fn declare -a arr for ((i=1; i<=4; i++)); do read -p "Enter name $i: " n arr+=("$n") done sort <(printf "%s\n" ${arr[@]}) > "$fn"