1.基于关键字搜索
syntax:grep [paramter] "keywords" filepath
[paramter]: -i ignore upper or lower case
-n show the located row number
-v show the row which not contain the "keywords"
-Ax show specific number of rows after the "keywords" located row
-Bx show specific number of rows after the "keywords" located row
eg: find / -user msdomain1\pzhou | grep 'keywords
grep -B3 "peter" /date/file
2. cut基于列处理文本
syntax: cut [paramter] file
paramter: -d point out he seperate words (default tab)
-f point out the numver of column which will be output
-c cut rows by index of character in each row
eg: cut -c2-6 /etc/passwrod show form 2 to 6 character of each row
cut -d: -f1 /ect/passwd
3. wc statistic infor of text
syntax: cut [params] file
params: -l number of rows
-w number of words
-c number of byte
-m number of character
4.sort text
syntax: sort [params] file
params: -r order by desc
-n sort by number
-f ingore upper or lower case
-u delete duplicated row
5.uniq delete duplicated labour rows
syntax: uniq file
6. compare two file
syntax: diff [param] file1 file2
params: -i ignore upper or lower case
-b ignore blank
-u make a output more uniform(use to make patch file)
7.check spell
syntax: aspell file
8.tranfer file
syntax: tr [params] < filepath
params: -d 'words' delete all 'words'
'a-z' 'A-Z' switch from lower case to upper case
9 replace workds
syntax: sed
eg: sed 's/word1/word2/g' file search(s) and replease all(globally g) word1 to replace word2
sed '1,50s/word1/word2/g' file search and replace for row 1to50
sed -e 's/word1/word2/g' -e 's/word3/word4/g' file iterate replace condition
sed -f conditionfilename file release replace condition from file
7.2 Linux 命令行文本处理
猜你喜欢
转载自oracle-api.iteye.com/blog/2171812
今日推荐
周排行