气昂昂的linux常用命令笔记
md5sum xx.txt 查看文件码
find -name “xxx”
wc -l 查看文件行数
wc -l xx.txt
free -g 查看机器还有多少内存
diff 路径a 路径b < diff.log 对比俩个文件夹的内容不一致的地方
在当前文件夹及子文件下查找.svn文件夹并递归删除
find . -name “.svn” -type d | xargs rm -rf
vim 里替换:aa全部替换为bb
:%s/aa/bb/g
统计m到n行中"字符串"出现的次数:
:m,ns/<字符串>//gn
统计"字符串"在当前编辑文件出现的次数
:%s/字符串//ng
dos2unix xxfile.sh 修改文件格式为linux
如果.nfs删不掉,可以用下面的方法:
lsof xxx
kill -9 pid
查看文件大小 du -d1 -h
查看文件的前多少行
head -10000 xx.log > temp.log
把xx.log文件前10000行的数据写入到temp.log文件中
查看文件的后多少行
tail -10000 xx.log > temp.log
把xx.log文件后10000行的数据写入到temp.log文件中
查看文件的几行到几行
sed -n ‘10,10000p’ xx.log > temp.log
把xx.log文件第10到10000行的数据写入到temp.log文件中
根据查询条件导出
cat xx.log | grep ‘cha’ > test.log 查找带cha字符的行重定向到test.log
grep -w “cha” xx.log > test.log 全词匹配查找
grep -n “cha” xx.log 查找并打印含cha字符串的行
创建软链接:ln -s /xx/xx/a.txt a.txt
文件排序
sort xx.log > sort_xx.log 排序文件将xx.log排序后重定向到sort_xx.log
文件按列输出
cat xx.log | awk ‘{print $7, $2, $3, $1}’ > new.log把xx.log的第7,2,3,1列的内容打印出来