tail
tail -f 2005-10-31.log
查看日志
-f 追加文件内容,可进行编辑
cat
cat /proc/cpuinfo
只读的形式打开文本文件
$cat >> filename << end
快速创建单个文件
就可以输入内容,以end为结尾。end都是可以自己定的,像在发邮件的时候,是以.点结束的所以可以用:
$cat >> filename << .
注意:如果使用tab键,注意,一些老版本的shell可能无法正确理解它的含义。为了解决这一问
题,可以在<<之后加一个横杠-,像这样:
cat >> myfile <<- end
cat testsetuplog2006-10-28 | awk '{print$3}' | sort -u | wc
cat testsetuplog2006-10-30 | awk '{print $6}' | grep 0 | wc
cat testsetuplog2006-11-15 | awk '($5$6==62) {print $4}' | sort -u | wc
在日志testsetuplog2006-11-15的每行中,第5列等于6,第6列等于2的行中,打印他们的第4列内容不重复的行数
cat ExportMac2005.txt > mac.txt
把ExportMac2005.txt的内容拷贝到另外一个文件mac.txt
cat ExportMac2006-01-01.txt >> mac.txt
把ExportMac2006-01-01.txt的内容追加到文件mac.txt
cat mac.txt | sort -u | wc
对mac.txt中的不重复内容条数进行统计
cat mac.txt | sort -u > macunique.txt
把mac.txt中的不重复内容条数拷贝到macunique.txt
grep
grep MyKeyword statistics.2006102700.log
grep MyKeyword statistics.2006102800.log | wc
grep MyKeyword statistics.2006102800.log | awk '{print$1}' | sort -u | wc
在日志statistics.2006102800.log的每行中出现过MyKeyword的行中,打印他们的第1列内容不重复的行数
wc 做统计 3个数字含义:行数,字符数,字节数
sort 排序 -u (unique) 不重复
awk 打印
grep 'Radius' *
在当前文件夹下的所有文件中搜索出现Radius的地方
wc
wc mac.txt
对mac.txt中的内容条数进行统计
find
find -name Main.cpp
搜索文件名为Main.cpp的文件所在路径
touch
touch xxx
创建新文件
rm
rm -rf WEB-INF
强制删除有内容的文件夹
rm xa*
删除所有xa开头的文件
split
split -l 10000 ExportMac.txt
把ExportMac.txt分割成多个文件,每个文件10000行
-l (lines) 行
cp
cp -a /usr/local/php /www/php
拷贝整个目录
ln
ln -s /usr/local/php/etc/php.ini /etc/php.ini
ln -s from to
软链接 不会占用磁盘空间
硬链接,没有参数-s, 会在生成一个和源文件大小相同的文件
文件都保持同步变化
s (symbolic)
linux-shell-cat,touch,tail,head,rm,mv,cp,ln,wc-文本操作
猜你喜欢
转载自hnsswjjxy-163-com.iteye.com/blog/909984
今日推荐
周排行