linux 常用命令
1.Grep
查找指定关键字之后10行
grep -A 10 'words' document.txt
查找指定关键字之前10行
grep -B 10 'words' document.txt
只显示指定内容
grep -o 'word' document.txt
2.Sort
排序文件内容,并去掉重复值
sort -u document.txt
3.tar
解压文件
tar -zvxf doc.tar.gz
从压缩文件解压特定文件
tar -zvxf doc.tar.gz <specific doc name>
4.tac
与cat相反,它是从文件末尾开始往前读取
tac file
读取最后一个匹配字符串之后的文件内容
tac file | grep foo -B2 -m1 | tac
5.date
查看机器启动时间
date -d "$(</proc/uptime awk '{print $1}') seconds ago"6.查看cpucores
cat /proc/cpuinfo | awk '/^processor/{print $3}' | tail -1