Bash 从用户处读取内容的脚本

Bash 从用户处读取内容的脚本,bash,shell,scripting,Bash,Shell,Scripting,如何编写创建文件的shell脚本 echo "Enter the file you want to create" read a touch $a 并将内容添加到创建的文件“a” echo "Enter the contents to your $a file:" cat > $a << 'EOF' EOF echo“输入$a文件的内容:” cat>$a您可以询问,然后进行简单的回音: echo "Enter the file you want to

如何编写创建文件的shell脚本

    echo "Enter the file you want to create"
    read a
    touch $a
并将内容添加到创建的文件“a”

echo "Enter the contents to your $a file:"
cat > $a << 'EOF'
EOF
echo“输入$a文件的内容:”

cat>$a您可以询问,然后进行简单的回音:

echo "Enter the file you want to create"
read file
echo "Enter the contents to your $a file:"
read content

echo "$content" > "$file"

您可以询问,然后进行简单的回显:

echo "Enter the file you want to create"
read file
echo "Enter the contents to your $a file:"
read content

echo "$content" > "$file"

您可以询问,然后进行简单的回显:

echo "Enter the file you want to create"
read file
echo "Enter the contents to your $a file:"
read content

echo "$content" > "$file"

您可以询问,然后进行简单的回显:

echo "Enter the file you want to create"
read file
echo "Enter the contents to your $a file:"
read content

echo "$content" > "$file"

你就快到了。这将满足您的要求:

echo "Enter the file you want to create"
read a
echo "Enter the contents to your $a file (press ctrl-D when done):"
cat >"$a"
讨论 无需触摸该文件。无论怎样,
cat
语句都将创建它

此外,由于文件名可以包含空格,因此最好将包含文件名的任何shell变量都用双引号引起来。这可以防止分词

cat > $a << 'EOF'
EOF

cat>$a你就快到了。这将满足您的要求:

echo "Enter the file you want to create"
read a
echo "Enter the contents to your $a file (press ctrl-D when done):"
cat >"$a"
讨论 无需触摸该文件。无论怎样,
cat
语句都将创建它

此外,由于文件名可以包含空格,因此最好将包含文件名的任何shell变量都用双引号引起来。这可以防止分词

cat > $a << 'EOF'
EOF

cat>$a你就快到了。这将满足您的要求:

echo "Enter the file you want to create"
read a
echo "Enter the contents to your $a file (press ctrl-D when done):"
cat >"$a"
讨论 无需触摸该文件。无论怎样,
cat
语句都将创建它

此外,由于文件名可以包含空格,因此最好将包含文件名的任何shell变量都用双引号引起来。这可以防止分词

cat > $a << 'EOF'
EOF

cat>$a你就快到了。这将满足您的要求:

echo "Enter the file you want to create"
read a
echo "Enter the contents to your $a file (press ctrl-D when done):"
cat >"$a"
讨论 无需触摸该文件。无论怎样,
cat
语句都将创建它

此外,由于文件名可以包含空格,因此最好将包含文件名的任何shell变量都用双引号引起来。这可以防止分词

cat > $a << 'EOF'
EOF
cat>$a