博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
50个常用的Linux命令
阅读量:7154 次
发布时间:2019-06-29

本文共 3050 字,大约阅读时间需要 10 分钟。

1.tar

tar -xvf archive_name.tar  解压文件

tar -cvf archive_name.tar file 把文件file压缩成archive_name.tar

tar -tvf archive_name.tar 查看压缩文件

2.grep

 grep 'this' demo_file   单个文件

 grep 'this' demo_*     多个文件

 grep -i "the" demo_file  忽略大小写

 grep "lines.*empty" demo_file

  • ? The preceding item is optional and matched at most once.
  • * The preceding item will be matched zero or more times.
  • + The preceding item will be matched one or more times.
  • {n} The preceding item is matched exactly n times.
  • {n,} The preceding item is matched n or more times.
  • {,m} The preceding item is matched at most m times.
  • {n,m} The preceding item is matched at least n times, but not more than m times.

grep -iw "is" demo_file   -w全文本匹配

grep -A 3 -i "example" demo_text  查找example之后,显示符合的后三行,-B之前的前几行,-C 之前之后的几行

grep -r 'py' CEE_api_test

grep -v "go" demo_text    查找不带‘go'的行

$ cat test-file.txtabcd$ grep -v -e "a" -e "b" -e "c" test-file.txtd grep -c "go" demo_text  查找go的个数6 grep -v -c this demo_file    不包含this的有几行 grep -l import *.py   查找以py结尾且包含import的文件 grep -n 'go' demo_text  显示带go的行数
grep -o "is.*line" demo_file  只显示符合查找patten的数据
grep -o -b "3" temp-file.txt2:38:3
https://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/ find -name 'MyCProgram.c'  找到名字为MyCProgram.c的文件 find -iname 'MyCProgram.c'  忽略大小写查找 find / -name passwd 指定路径查找文件 find / -maxdepth 2 -name passwd  最大深度为2级 find / -maxdepth 3 -name passwd  1,2,3级的都显示出来 find -mindepth 3 -maxdepth 5 -name passwd  解释Find the password file between sub-directory level 2 and 4. find -iname 'MyCProgram.c' -exec md5sum {} \; find -maxdepth 1 -not -iname 'MyCProgram.c'   查找文件不是MyCProgram.c的文件;
# touch "test-file-name"# touch "test-file-name "[Note: There is a space at the end]# ls -1 test*test-file-nametest-file-name
# ls -i1 test*16187429 test-file-name16187430 test-file-name
find -inum 16187430 -exec mv {} new-test-file-name \;# ls -i1 *test*16187430 new-test-file-name16187429 test-file-name
find -inum 16187430 -exec mv {} new-test-file-name \;
find ~ -empty   Find all empty files (zero byte file) in your home directory and its subdirectory
find . -type f -exec ls -s {} \; | sort -n -r | head -5   Finding the Top 5 Big Files
find . -type f -exec ls -s {} \; | sort -n  | head -5   Finding the Top 5 Small Files
find . -not -empty -type f -exec ls -s {} \; | sort -n  | head -5   other than the ZERO byte files. find . -type s   Find only the socket files.
find . -type d   Find all directories
find . -type f   Find only the normal files
find . -type f -name ".*"   Find all the hidden files
find -type d -name ".*"    Find all the hidden directories
find ~ -size +100M   Find files bigger than the given size,Note: – means less than the give size, + means more than the given size, and no symbol means exact given size.
alias rmao="find . -iname a.out -exec rm {} \;"rmao
find / -type f -name *.zip -size +100M -exec rm -i {} \;"   The following command removes *.zip files that are over 100M.
 
 

 

 

 

 

 

 

 

 

 

文章出处:http://gywbd.github.io/posts/2014/8/50-linux-commands.html

转载于:https://www.cnblogs.com/william126/p/10369322.html

你可能感兴趣的文章
Java与.Net中的泛型:真与伪,优与劣
查看>>
jquery学习以及下载链接
查看>>
[EmguCV|WinForm] 使用EmguCV內建直方圖工具繪製直方圖(Histogram)-直方圖(Histogram)系列 (1)...
查看>>
openjudge1768 最大子矩阵[二维前缀和or递推|DP]
查看>>
JSP学习初体验
查看>>
Linux 下一个很棒的命令行工具
查看>>
oracle 索引的(创建、简介、技巧、怎样查看)
查看>>
H5视频播放器属性与API控件,以及对程序的解释
查看>>
C++类的大小(转)
查看>>
Node+Express的跨域访问控制问题:Access-Control-Allow-Origin
查看>>
-03-PetaLinux通过eMMC方式启动【Xilinx-Petalinux学习】
查看>>
Scala进阶之路-Scala特征类与unapply反向抽取
查看>>
Portable way to get file size (in bytes) in shell?
查看>>
C++空类中的默认函数
查看>>
浅谈程序猿的职业规划,看你如何决定自己的未来吧。
查看>>
IOS debug网络PonyDebugger 实践篇
查看>>
Android 如何预置APK M
查看>>
《JAVA与模式》之命令模式
查看>>
U盘FAT32转换NTFS格式
查看>>
【iCore3双核心板】发布 iCore3 应用开发平台硬件原理图
查看>>