find /opt/ylbzj/renkoudata/ -name "cbry_child*.txt"|xargs grep 130982199906081155
du -h --max-depth=1 2>/dev/null | sort -hr
netstat -ntlp|grep 8823
rpm -qa|grep epel
简单替换
sed -i 's/原字符串/新字符串/g' /home/1.txt
批量替换(grep '需要替换的字符' -rl 路径|xargs sed -i 's/原始字符/新字符/g')
grep '123456:8089' -rl . |xargs sed -i 's/123456/111.63.208.5/g'
打印passwd的3到10行
sed -n '3,10'p passwd
打印passwd 中包含 ‘root’ 的行
sed -n '/root/'p passwd
删除passwd 的15行以及以后所有行
sed '15,$'d passwd
删除passwd中包含 ‘bash’ 的行
sed '/bash/'d passwd
替换passwd 中 ‘root’ 为 ‘toor’
sed 's/root/toor/g' passwd
替换passwd中 ‘/sbin/nologin’ 为 ‘/bin/login’
sed 's#sbin/nologin#bin/login#g' passwd
删除passwd中5到10行中所有的数字
sed '5,10s/[0-9]//g' passwd
删除passwd 中所有特殊字符(除了数字以及大小写字母)
sed 's/[^0-9a-zA-Z]//g' passwd
把passwd中第一个单词和最后一个单词调换位置
sed 's/\(^[a-zA-Z][a-zA-Z]*\)\([^a-zA-Z].*\)\([^a-zA-Z]\)\([a-zA-Z][a-zA-Z]*$\)/\4\2\3\1/' passwd
把passwd中出现的第一个数字和最后一个单词替换位置
sed 's#\([^0-9][^0-9]*\)\([0-9][0-9]*\)\([^0-9].*\)\([^a-zA-Z]\)\([a-zA-Z][a-zA-Z]*$\)#\1\5\3\4\2#' passwd
把passwd 中第一个数字移动到行末尾
sed 's#\([^0-9][^0-9]*\)\([0-9][0-9]*\)\([^0-9].*$\)#\1\3\2#' passwd
在passwd 20行到末行最前面加 ‘aaa:’
sed 's/^.*$/&aaa/' passwd
wc -l 文件名
- 网络抓包命令 抓tcp的80端口输出到 captcha22.cap
tcpdump -tttt -s0 -X -vv tcp port 80 -w captcha22.cap
## 不区分大小写列出内容和文件
find .|xargs grep -ri '特定内容'
## 只列出文件
find .|xargs grep -ril '特定内容'
## 查找文件和文件夹 / 可替换为特定目录 如:/opt
find / -name 'filename'
## 查找文件夹
find / -name 'path' -type d
## 查找文件
find / -name 'fileName' -type f
网友评论