-1

我一直在努力读取信息并将其存储到 .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

我错过了一些明显的东西吗?

4

2 回答 2

0

.dat file is like a simple text file you can read and write in a normal way

echo "Today's date is" date >> stored.dat
date >> stored.dat
cat stored.dat
于 2018-07-12T06:23:10.697 回答
0

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

#!/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
于 2018-07-12T06:08:08.537 回答