?? pb.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" 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 + -