RHEL-RH134-UNIT6-文本处理工具

#########diff 文件比对###########
diff file file1
diff -c file file1
diff -u file file1 >file.path
patch file file.patch
patch -b file file.patch


##########grep#################
grep -i 忽略大小写
-n 显示关键字的所在行
-c 显示过滤后的行数
-v 反向过滤
-E 多文件过滤“关键字1|关键字2”
-r 在目录中查找含有关键字的文件
注意: ^关键字 以关键字开头
关键字$ 以关键字结尾



ifconfig bro |grep inet |grep inet6 -v |awk -F " " '{PRINT $2}'


#########sort&&uniq用法########


sort -n file  ##按数值排列
-rn file  ##倒序
-rnu file  ##去除重复并倒序排列
-rn file  ##
sort -rn file | uniq -c
sort -rn file | uniq -d
sort -rn file | uniq -n
sort -rn file | uniq -u




ps ax -o pid --sort -%mem |grep -v PID|head -n 5
#########sed#######################
sed 's/原字符/替换字符/g' file
sed -e '策略1' -e '策略2' file
sed -i file ##把转换后的内容输出到指定文件
sed '3,5s/原字符/替换字符/g' file
sed 5x passwd
5d
5p
-n 3,5p
-ne 3p -ne 5p
crate_user /mnt/userfile /mnt/passwdfile


[root@foundation8 mnt]# cat create_user.sh 
#!/bin/bash
MAX_LINE=`wc -l $1 |awk -F " " '{print $1}'`
for NUM in `seq 1 $MAX_LINE`
do 
USERNAME=`sed -n ${NUM}p $1`
PASSWORD=`sed -n ${NUM}p $2`
useradd $USERNAME
echo $PASSWORD|passwd --stdin $USERNAME
done



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值