⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pb.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# pb.sh: phone book# Written by Rick Boivie, and used with permission.# Modifications by ABS Guide author.MINARGS=1     #  Script needs at least one argument.DATAFILE=./phonebook              #  A data file in current working directory              #+ named "phonebook" must exist.PROGNAME=$0E_NOARGS=70   #  No arguments error.if [ $# -lt $MINARGS ]; then      echo "Usage: "$PROGNAME" data-to-look-up"      exit $E_NOARGSfi      if [ $# -eq $MINARGS ]; then      grep $1 "$DATAFILE"      # 'grep' prints an error message if $DATAFILE not present.else      ( shift; "$PROGNAME" $* ) | grep $1      # Script recursively calls itself.fiexit 0        #  Script exits here.              #  Therefore, it's o.k. to put              #+ non-hashmarked comments and data after this point.# ------------------------------------------------------------------------Sample "phonebook" datafile:John Doe        1555 Main St., Baltimore, MD 21228          (410) 222-3333Mary Moe        9899 Jones Blvd., Warren, NH 03787          (603) 898-3232Richard Roe     856 E. 7th St., New York, NY 10009          (212) 333-4567Sam Roe         956 E. 8th St., New York, NY 10009          (212) 444-5678Zoe Zenobia     4481 N. Baker St., San Francisco, SF 94338  (415) 501-1631# ------------------------------------------------------------------------$bash pb.sh RoeRichard Roe     856 E. 7th St., New York, NY 10009          (212) 333-4567Sam Roe         956 E. 8th St., New York, NY 10009          (212) 444-5678$bash pb.sh Roe SamSam Roe         956 E. 8th St., New York, NY 10009          (212) 444-5678#  When more than one argument is passed to this script,#+ it prints *only* the line(s) containing all the arguments.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -