1.rpm安装和卸载包
rpm -ivh /root/Desktop/notepad.rpm,如果出现了错误提示“error: Faild dependencies”则表明出现了软件包依赖问题,下面会有提示需要哪个文件,安装完哪个文件后(google 一个)再次安装即可。也可以在上述命令的后面加上--nodeps 强制安装。
rpm -e notepad,删除rpm软件包
rpm -qa |grep ssh,查询安装包
2.计算文件行
wc filename -l
cat a.txt |grep 甘亮 |wc -l
3.查看动态日志 tail -f cantalina.out
查看文件最后5行 tail -5 a.txt
4.复制到远程机 : scp /home/work/a.txt 192.168.3.23:~/
` a.txt文件被复制到了192.168.3.23
5.ps -ef |grep 'tomcat',查看进程中是否含有'tomcat'字符在进程中,kill -9 进程号
6.head -n 1000 engine_20120501_1.log > text2.log 将日志engine_.log前1000行复制到text2.log
同样也可以查看前十行数据; head -n 10 engine.log
7.列出文件树
find . -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/'
find . -type d -print 2>/dev/null|awk '!/\.$/ {for (i=1;i<NF;i++){d=length($i);if ( d < 5 && i != 1 )d=5;printf("%"d"s","|")}print "---"$NF}' FS='/'
8.
过滤包含字符的文件的行
awk 'index($0,"中国人")>=1 {print $0}' engine_20120103.log
awk -F "[][&]" 'index($13,"lk=")>=1 && length($13)>3 { print( $0);}' log.log//制定切分符号(&)及判断条件
9.infobright启动:/etc/init.d/mysql.d-ib stop|start
10.cp -r src dst ->递归复制目录
cd - ->返回上次访问目录
grep -l 甘亮 /home/ganliang/* 在'/home/ganliang'目录下查找含'甘亮'的文件
sed -n 1,20p input.txt 输出1至20行的日志
sed '2,10d' input.txt 删除2,10行
sed '/^20121121/!d' file 删除文件中不以20121121开头的行
sed -i '/甘亮/d' input.sh 删除含有“甘亮”字串的行
sed -i 's/abc/ABC/g'input.txt 将文件input.txt的所有'abc'字符串替换成'ABC'
split -3 a.txt 每3行分割一个小文件
date "+%Y_%m_%d %H:%M:%S" #2014_01_10 11:49:38
11. awk '/aaa|bbb/' a.log ->查找含有'aaa'或'bbb'字串的行
12. du -h --max-depth=1 统计当前目录文件总大小。
linux 相关命令必杀技
猜你喜欢
转载自ganliang13.iteye.com/blog/1614059
今日推荐
周排行