Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.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
Linux 如何在.dat文件中存储信息_Linux_Bash_Fedora20 - Fatal编程技术网

Linux 如何在.dat文件中存储信息

Linux 如何在.dat文件中存储信息,linux,bash,fedora20,Linux,Bash,Fedora20,我一直在努力读取信息并将其存储到.dat文件中,但每次运行bash脚本时,它似乎运行正常,但我创建的.dat文件是空的 这是我的密码: #!/bin/bash echo "Please enter student's name:" read student echo "$student" ((count = 0)) while read students[$count] ; do ((count++)) done < sorted.dat #/bin/bash echo“请输入学生姓名

我一直在努力读取信息并将其存储到.dat文件中,但每次运行bash脚本时,它似乎运行正常,但我创建的.dat文件是空的

这是我的密码:

#!/bin/bash
echo "Please enter student's name:"
read student
echo "$student"
((count = 0))

while read students[$count] ; do
((count++))
done < sorted.dat
#/bin/bash
echo“请输入学生姓名:”
读书的学生
回音“$student”
((计数=0))
阅读时学生[$count];做
((count++)
完成

我是否遗漏了一些明显的内容?

也许您必须将学生存储在文件中

#!/bin/bash
echo "Please enter student's name:"
read student
echo "$student" >> sorted.dat
((count = 0))

while read students[$count] ; do
((count++))
done < sorted.dat
#/bin/bash
echo“请输入学生姓名:”
读书的学生
echo“$student”>>sorted.dat
((计数=0))
阅读时学生[$count];做
((count++)
完成
.dat文件就像一个简单的文本文件,您可以用正常的方式读写

echo "Today's date is" date >> stored.dat
date >> stored.dat
cat stored.dat

我会删除
((count=0))
,只使用
学生=($(你能解释一下你想做什么吗?回答者目前正在猜测。你的观察非常敏锐
:)