#!/bin/bash
cat phonebook|nl |sed 's/^ */ /g'>/tmp/book.tmp
line=$(grep "$1" /tmp/book.tmp |cut -f1)
if [ "$line" -eq 1 ]
then
next_line=$(( line + 1 ))
cat /tmp/book.tmp|sed -n ${line},${next_line}p
exit 0
fi
previous_line=$(( line - 1 ))
next_line=$(( line + 1 ))
cat /tmp/book.tmp|sed -n ${previous_line},${next_line}p
exit 0
阅读(370) | 评论(0) | 转发(0) |