1.
# 编写脚本实现将/usr/local/test目录下大于100K文件,将它拷贝到/tmp目录下
#!/bin/bash
for file in `ls /usr/local/test`
do
if [ -f $file ];then
if [ `ls -l $file`|awk '{print $5}' -gt 10000];then
mv $file /tmp/
fi
fi
done
2.
#已知test.txt文件内容如下,请取出文件的5-15行内容
#方法一:
[root@i ~]# grep 15bbbbbb -B 10 test.txt
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb
#方法二:
[root@i ~]# sed -n '5,15p' test.txt
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb
#方法三:
[root@i~]# awk '{if(NR<16 && NR>4) print $1}' test.txt
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb
3.