Linux 常用命令汇总

一、打包压缩解压

①压缩

tar -czvf Test.tar.gz ./Test

tar -cjvf Test.tar.bz2 ./Test

②解压

tar -xzvf Test.tar.gz

tar -xjvf Test.tar.bz2

 

-c, --create: create a new archive

-z, --gzip: filter the archive through gzip

-v, --verbose: verbosely list files processed

-f, --fIle=ARCHIVE: use archive file or defice ARCHIVE

-j, --bzip2: filter the archive through bzip2

-x, --extract, --get: extract files from an archive

 

二、查找替换

①. 查找指定目录下某一文件

find ./ -name filename

②. 查找指定目录下文件中的字符串

grep -r --color "Str" ./

③. 替换指定目录下文件中的字符串

grep -rl printf ./ | xargs sed -i 's/printf/xxxxxx/g'     --printf -->> xxxxxx

④. 严格匹配替换指定目录下文件中的字符串

grep -rl "printf" ./ | xargs sed -i 's/\<printf\>/xxxxxx/g'

 MAC:

grep -rl "printf" ./ | xargs sed -i "" 's/printf/xxxxxx/g'

grep -rl "printf" ./ | xargs sed -i ".bak" 's/printf/xxxxxx/g'

 

grep 选项介绍

-r, -R, --recursive: Read  all  files  under  each  directory,  recursively

-l: Suppress  normal  output; instead print the name of each input file from which output would normally have been printed.

 

三、混合指令

① 远程拷贝
scp -r root@
192.168.1.102:/home/lk /root

② 内存泄漏检测
valgrind --tool=memcheck --leak-check=full ./Test

③ 显示磁盘IO速度
iostat -d -K 2

posted @ 2018-06-25 22:26  99度的水  阅读(143)  评论(0编辑  收藏  举报