当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
shellscript写的通迅录
发布时间:2010/11/12 11:31:24 来源:城市学习网 编辑:ziteng
  pl文件:
  #!/bin/bash
  #read n p
  PL='phonelist'
  if [ $1 == 'c' ]
  then
  rm -f $PL
  touch $PL
  echo 'cleaned all persons'
  exit 0
  fi
  if [ $# -eq 1 ] && [ $1==v ]
  then
  cat $PL
  exit 0
  fi
  if [ $# -ne 2 ]
  then
  if [ $# -eq 3 ] && [ $1 == 'm' ]
  then
  #read -p 'put the person name:' n
  #read -p 'change name to:' nn
  #read -p 'change number to:' np
  cat $PL|grep -v $2>$PL
  echo -e $2'\t'$3>>$PL
  cat $PL
  else
  echo 'person name and phone number must not be empty!'
  fi
  exit 1
  fi
  if [ $1 == 'd' ]
  then
  cat $PL|grep -v $2>$PL
  echo 'delete person ' $2' successfully!'
  else
  echo -e $1'\t'$2>>$PL
  echo 'succesfully add a phone number'
  cat $PL|grep $1
  fi
  exit 0
  运行:
  1 ./pl 伟子 13699520723
  添加联系人伟子,手机号码为13699520723
  2 ./pl d 伟子
  删除联系人伟子
  3 ./pl m 伟子 15866432516
  修改联系人伟子的手机号码为15866432516
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved