8.awk 读两遍文件的方法
test test
9. 如何快速统计一个大文件的行数
grep -Fc "" file
wc -l file
10.对齐文件
column -t file
11.删除空行
d 22
f 1
s 2
e 5
d 3
fdsafsa 4
sed '/^$/d' file
#不能删除有空格的行
awk 'NF+=0' file
12.循环写法
while [ : ]
while [ 1 ]
while true
13.awk system函数使用
echo aa bb | awk '{print $1;system("printf $(hostname)");print "\n"$2}'
awk 'BEGIN{system("echo "'"$abc"'"")}'
14.如何查找某个时间段的文件
-rw-r----- 1 root root 2.5M 02-19 11:01 mysql-bin.004594
-rw-r----- 1 root root 2.1M 02-19 12:01 mysql-bin.004595
-rw-r----- 1 root root 1.5M 02-19 13:01 mysql-bin.004596
-rw-r----- 1 root root 1.8M 02-19 14:01 mysql-bin.004597
-rw-r----- 1 root root 2.1M 02-19 15:01 mysql-bin.004598
-rw-r----- 1 root root 1.8M 02-19 16:01 mysql-bin.004599
-rw-r----- 1 root root 1.7M 02-19 17:01 mysql-bin.004600
-rw-r----- 1 root root 1.3M 02-19 18:01 mysql-bin.004601
-rw-r----- 1 root root 892K 02-19 19:01 mysql-bin.004602
-rw-r----- 1 root root 1.6M 02-19 20:01 mysql-bin.004603
-rw-r----- 1 root root 1.2M 02-19 21:01 mysql-bin.004604
-rw-r----- 1 root root 891K 02-19 22:01 mysql-bin.004605
-rw-r----- 1 root root 745K 02-19 23:01 mysql-bin.004606
-rw-r----- 1 root root 547K 02-20 00:01 mysql-bin.004607
-rw-r----- 1 root root 149 02-20 01:01 mysql-bin.004608
-rw-r----- 1 root root 149 02-20 02:01 mysql-bin.004610
-rw-r----- 1 root root 149 02-20 03:01 mysql-bin.004611
-rw-r----- 1 root root 149 02-20 04:01 mysql-bin.004612
-rw-r----- 1 root root 149 02-20 05:01 mysql-bin.004613
比如我想找出02-19 11:01到02-20 03:01之间的文件,脚本如何写?或者有没其他更便捷的办法?
可以用find来查找某个时间期间的文件吗?系统是centos 5.5的。
touch -d "2012-02-19 11:01" file1
touch -d "2012-02-20 03:01" file2
find $dir -newer file1 -a ! -newer file2 -a type f -print
阅读(1341) | 评论(0) | 转发(0) |