7.2 Linux 命令行文本处理

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_26182553

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值