linux系统管理技巧(一)

简介:

整理其比较实用的好的程序,并翻译过来。

一、在当前目录及子目录下搜索所有后缀为 .php 的文件,并且将 字符串 baidu.com 替换成 opendoc.com.cn
find -name *.php |xargs perl -pi -e 's|baidu.com|opendoc.com.cn|g';
sed -i "s/baidu.com/opendoc.com.cn/g" `grep baidu.com -rl ./`

二、将当前目录文件名全部转换成小写
for i in *; do mv "$i" "$(echo $i|tr A-Z a-z)"; done

三、查找二个文件相同的内容
grep -Fx -f file1 file2
sort file1 file2 | uniq -d

四、查找file2里 file1里没有的内容
grep -Fxv -f file1 file2

五、自动更新SVN的一个目录
for d in $(find . -maxdepth 1 -type d -name '[^.]*'); do cd "$d"; svn up; cd ..; done

六、查找当前文件列表 文件与组没有修改时间排序
find . -type f | xargs ls -ltrhg
l: 所有信息
t: 修改时间排序
r: 倒序
h: 大小 M K
g: 用户组

七、找到文件,将其与一个可读的信息输出列表
find . -type f | sed 's,.*,stat "&" | egrep "File|Modify" | tr "\\n" " " ; echo ,' | sh | sed 's,[^/]*/\(.*\). Modify: \(....-..-.. ..:..:..\).*,\2 \1,' | sort

find . -type f -exec ls -tr {} +

find . -type f | sed 's,.*,stat "&" | egrep "File|Modify" | tr "\\n" " " ; echo ,' | sh | sed 's,[^/]*/\(.*\). Modify: \(...........\).*,\2 \1,' | sort

ls -rl --time-style=+%s * | sed '/^$/,/^total [0-9]*$/d' | sort -nk6

八、查找文件和他们按修改时间排序的列表
ls -rl --time-style=+%s * | sed '/^$/,/^total [0-9]*$/d' | sort -nk6

九、查找N天前的文件,按时间排序
find . -type f -mtime -14 -exec ls -ltd \{\} \; | less

十、配置PS aliases
export PSOA='user,pid,time,state,command' ; function _ps { /bin/ps $@ ; } ; alias psa='_ps ax -o

$PSOA'
#ps aliases
PSO='user,pid,ppid,%cpu,%mem,time,start,state,command'
PSOA='user,pid,time,state,command'
PSOL='user,pid,ppid,%cpu,%mem,nice,pri,etime,time,tt,state,ucomm'
export PSO PSOA PSOL
function _ps { /bin/ps $@ ; }
alias ps='_ps ax -o $PSO'
alias psa='_ps ax -o $PSOA'
alias psl='_ps ax -o $PSOL'
alias psm='_ps -U $USER -o $PSOA'

十一、逐渐打印各行
awk 'BEGIN{ORS=""}NR!=1&&FNR==1{print "\n"}{print}END{print "\n"}' *.txt



本文转自守住每一天51CTO博客,原文链接:http://blog.51cto.com/liuyu/324498,如需转载请自行联系原作者


相关文章
|
6天前
|
资源调度 JavaScript 搜索推荐
Linux系统之部署envlinks极简个人导航页
【4月更文挑战第11天】Linux系统之部署envlinks极简个人导航页
40 2
|
9天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
59 0
|
9天前
|
监控 Unix Linux
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
Linux操作系统调优相关工具(四)查看Network运行状态 和系统整体运行状态
26 0
|
16天前
|
存储 前端开发 Linux
Linux系统之部署ToDoList任务管理工具
【4月更文挑战第1天】Linux系统之部署ToDoList任务管理工具
61 1
|
18天前
|
存储 传感器 运维
linux系统资源统计工具
【4月更文挑战第1天】Linux系统监控工具如dstat、htop、glances、vmstat、top、iostat、mpstat、sar和atop,用于跟踪CPU、内存、磁盘I/O、网络和进程性能。这些工具提供实时、交互式和历史数据分析,助力管理员优化系统性能和故障排查。例如,dstat是vmstat等工具的增强版,htop提供彩色界面的进程管理,而atop则结合了多种功能并记录历史数据。
27 5
linux系统资源统计工具
|
7天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
20 6
|
17天前
|
Ubuntu 架构师 Java
Linux系统常用命令非常详细建议收藏
Linux系统常用命令非常详细建议收藏
48 0
|
2天前
|
运维 网络协议 Unix
18.系统知识-Linux常用命令
18.系统知识-Linux常用命令
|
9天前
|
安全 Unix Linux
一、linux 常用命令之 linux版本信息 系统管理与设置 持续更新******
一、linux 常用命令之 linux版本信息 系统管理与设置 持续更新******
14 0
|
11天前
|
Prometheus 监控 Cloud Native
【Linux】查看系统内存命令(详细讲解)
【Linux】查看系统内存命令(详细讲解)