二.linux进阶指令
1.find查找指令
find 目录名 [选项] 查找文件
目录名省略=.=当前目录
book@www.100ask.org:~$ find -name "*.c"
./Documents/test2/a.c
./Documents/test2/b.c
./Documents/test2/test4/a.c
./Documents/test2/test4/b.c
book@www.100ask.org:~$ find . -name "*.c"
./Documents/test2/a.c
./Documents/test2/b.c
./Documents/test2/test4/a.c
./Documents/test2/test4/b.c
根据时间查找有变化的文件
find /home -mmin -30 查找/home目录下30分钟内有变动的文件
book@www.100ask.org:~$ find -mmin -30
.
./.cache/upstart
./.cache/upstart/hud.log
./.config/dconf
./.config/dconf/user
./.viminfo
./Documents/test2
./Documents/test2/a.c
./Documents/test2/b.c
2.grep查找指令
grep -rn “字符串” 文件名
文件名若为,则表示当前目录下的所有文件*
book@www.100ask.org:~$ grep -rn "this is a.c" *
Documents/test2/a.c:3:this is a.c
book@www.100ask.org:~$
3.压缩与解压缩指令
(1)单个文件的压缩与解压:一般情况下,小文件使用gzip来压缩,大文件使用bzip2来压缩
gzip 待压缩文件名:压缩文件,不保留与源文件
gzip -(k)l 待压缩文件名
gzip -(k)d 压缩文件名:-k表示保留源文件
book@www.100ask.org:~/Documents$ cd test1
book@www.100ask.org:~/Documents/test1$ touch gzip1test.c gzip2test.c
book@www.100ask.org:~/Documents/test1$ touch bziptest1.c bziptest2.c
book@www.100ask.org:~/Documents/test1$ gzip gzip1test.c
book@www.100ask.org:~/Documents/test1$ ls
bziptest1.c bziptest2.c gzip1test.c.gz gzip2test.c
book@www.100ask.org:~/