shellp

echo “1.建文件”
echo “2.写文件”
echo “1.读文件”
echo “1.查内容”
echo “1.改内容”

add(){
read -p “输入总人数” n
for (( i = 0; i < n; i++ )); do
read -p “编号” a[i]
read -p “姓名” n[i]
read -p “性别” b[i]
read -p “年龄” c[i]
echo “a[i],n[i],b[i],c[i]”;
done>shuju.txt
exit 1
}

prt(){
read -p “库名” myfile
touch $myfile
read -p “人员数” n
for((i=1;i<=n;i++));do
read a[i],k[i],b[i],c[i];
echo ${a[i]},${k[i]},${b[i]},${c[i]};
done<$myfile
}

build(){
read -p “文件名:” filename
touch filename
ls

}

show(){
read -p “文件名:” filename
for i in $(cat filename)
do
a[i]=$i
echo ${a[i]}
done
}

modi(){
read -p “文件名:” filename
read -p “输入总人数” n
for (( i = 0; i < n; i++ )); do
read -p “编号” a[i]
read -p “姓名” n[i]
read -p “性别” b[i]
read -p “年龄” c[i]
echo “a[i],n[i],b[i],c[i]”;
done>filename
exit 1
}

read -p “请选择” n
case $n in
1) build;;
2) add;;
3) prt;;
4) show;;
5) modi;;
*) break;;
esac

发表评论

邮箱地址不会被公开。 必填项已用*标注