编写一个存储联系人姓名和电话号码的contact.sh程序,要求每次运行程序是输入的联系人信息都保存在“姓名简拼.txt”文件中,永不丢失,并且进行测试。#Linux
#!/bin/bash
if [ ! -f "contacts.txt" ]; then
touch "contacts.txt"
fi
echo "Enter name:"
read name
echo "Enter phone number:"
read phone
echo "$name $phone" >> "contacts.txt"
echo "Contact added."
chmod +x contact.sh
./contact.sh