文章浏览 复制本页面地址

Linux 常用便捷命令积累.

1、 批量查找替换:

方法一、

把前面的替换为后面的

find -name '*.php' | xargs perl -pi -e 's|http://lead.soperson.com/10003922/10007730.js|http://www.abc/common.js|g'

方法二、把braveisgoodguy 替换为 helloworld,查找文件类型为.php

sed -i "s/braveisgoodguy/helloworld/g" `find . -name "*.php"|xargs grep braveisgoodguy -rl`

 

2.查找文件内容:

显示文件查找出包含内容的文件的名字包括路径

find . -type f -name '*.php'  -exec grep 'helloworld'  -l {} \;

 

3. 查看端口所占用的进程

netstat -nlp | grep 3306

ps -aux | grep 3306

4. awk 使用

netstat -nlp | grep :3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      23946/mysqld

比如说我只想抓出端口号

netstat -nlp | grep :3306 | awk '{print $7}' | awk -F '/' '{print $1}'

5. cp 拷贝略过指定目录FaceGame

rsync -vauP --exclude="FaceGame" ./* ../bravedufile/haiershangcheng

 

标签:
上一篇:
下一篇: