###GREP###
Features:
1. Line Processor
Tasks:
1. Use grep to search for interesting strings
a. 'grep cat animals.txt' - returns ALL lines containing lowercase 'cat
b. 'grep -i cat animals.txt' - returns ALL lines containing either case of 'cat
c. 'grep 20 animals.txt'
d. 'grep "^20" animals.txt' - returns line that are anchored with the string: '20'
e. 'grep "20$" animals.txt' - returns lines that end with the string: '20'
f. 'grep "^20$" animals.txt' - returns lines beginning and ending with the string: '20'
g. 'grep "^c.*" animals.txt' - returns lines beginning with 'c'
h. 'grep "^[c|d]" animals.txt' - returns lines beginning with 'c' OR 'd'
i. 'grep -v "kernel" /var/log/message' - returns lines htat do NOT contain 'kernel'
j. 'grep -C 2 'dog' animals.txt' - returns 2 lines above and below matched line
j1. 'grep -C 2 'lstrich' animals.txt > animals.reduced.list.txt
###Linux Redirection & Pipes###
Features:
1. Ability to control input and output
Input redirection '<':
1. 'cat < 123.txt'
Note: Use input redirection when program does NOT default to file as input
Output redirection '>':
1. 'cat 123.txt > onetwothree.txt'
Note: Default nature is to:
1. Clobber the target file
2. Populate with information from input stream
Append redirection '>>":
1. 'cat 123.txt >> numbers.txt' - creates 'numbers.txt' if it doesn't exist, or appends if it does
2. 'cat 456.txt >> numbers.txt'
Pipes '|':
Features: Connects the output stream of one command to the input stream of a subsequent command
1. 'cat 123.txt | sort
2. 'cat 234.txt 123.txt | sort
3. 'cat 456.txt 123.txt | sort | grep 3
RH135-4-regexes
原创
©著作权归作者所有:来自51CTO博客作者williamherry的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
C语言学习4
学习第四天打卡
全局变量 寄存器 局部变量