sgrep

来自「Berkely的学生写的」· 代码 · 共 28 行

TXT
28
字号
#!/bin/sh# Chapter 16 - Answer to Question 1# This function is an implementation of the grep command# using sed/shell# You will need to "source" this file into your environment# using the . command.sgrep() {    if [ $# -lt 2 ] ; then         echo "USAGE: sgrep pattern files" >&2        exit 1    fi    PAT="$1" ; shift ;        for i in $@ ;     do        if [ -f "$i" ] ; then            sed -n "/$PAT/p" $i        else            echo "ERROR: $i not a file." >&2        fi    done        return 0}

⌨️ 快捷键说明

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