linux command grep

Linux command grep

Purpose

       Learning how to use grep commad, we will introduce three methods.

 

Eevironment

       Ubuntu 16.04 terminal

 

Procdeure

      

example1:

# check for whitespace in $SRC and exit for safety reasons

grep -q "[[:space:]]" <<<"${SRC}" && { echo "\"${SRC}\" contains whitespace. Not supported. Aborting." >&2 ; exit 1 ; }

 

example:2

# find specific string   $String

grep  $String   ./   -r  -n 

 

 example:3

# loopup does not start with # and space line

grep -v  ^#  ./conf/hbase-env.sh   |  grep  -v ^$

 

posted @ 2019-01-24 13:55  嵌入式实操  阅读(322)  评论(0编辑  收藏  举报