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.txt
a
b
c
d $ grep -v -e "a" -e "b" -e "c" test-file.txt
d 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.txt
2:3
8: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-name
test-file-name
# ls -i1 test*
16187429 test-file-name
16187430 test-file-name
find -inum 16187430 -exec mv {} new-test-file-name \;

# ls -i1 *test*
16187430 new-test-file-name
16187429 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

50个常用的Linux命令的更多相关文章

  1. 50个常用的Linux命令(二)sed

    [root@localhost cee]# echo this thisthisthis |sed 's/this/THIS/g'THIS THISTHISTHIS[root@localhost ce ...

  2. 50个常用的Linux命令(三)基础实例

    ls ls -als -l == llls -Aldrwxrwxrwx.  2 root   root       6 Dec 21 20:38 Videos-rwxrwxrwx   1 root   ...

  3. 50个常用的Linux命令(三)awk

    [root@localhost cee]# echo -e "line1\nline2"|awk '{ print }'line1line2[root@localhost cee] ...

  4. 每天一个linux命令(61):vi命令 /企业常用的linux命令清单

    vi/vim 的使用 基本上 vi/vim 共分为三种模式,分别是一般模式.编辑模式与指令列命令模式. 这三种模式的作用分别是: 一般模式:以 vi 打开一个档案就直接进入一般模式了(这是默认的模式) ...

  5. 工作中常用的Linux命令:mkdir命令

    本文链接:http://www.cnblogs.com/MartinChentf/p/6076075.html (转载请注明出处) 在Linux系统中,mkdir命令用来创建一个目录或一个级联目录. ...

  6. 工作中常用的Linux命令:crontab命令

    本文链接:http://www.cnblogs.com/MartinChentf/p/6060252.html (转载请注明出处) crontab是一个用来设置.删除或显示供守护进程cron执行的定时 ...

  7. 工作中常用的Linux命令:ipcs/ipcrm命令

    本文链接:http://www.cnblogs.com/MartinChentf/p/6057100.html (转载请注明出处) ipcs 1. 命令格式 ipcs [resource-option ...

  8. 工作中常用的Linux命令:find命令

    本文链接:http://www.cnblogs.com/MartinChentf/p/6056571.html (转载请注明出处) 1.命令格式 find [-H] [-L] [-P] [-D deb ...

  9. 开发过程中常用的Linux命令

    做Java开发好几年了,部署JavaWeb到服务器上,一般都选择Linux,Linux作为服务器真是不二之选,高性能,只要熟悉Linux,操作快捷,效率很高. 总结一下工作中常用的Linux命令备忘: ...

随机推荐

  1. servlet容器、IOC容器、SpirngMVC

    servlet容器(这里指tomcat插件)存放servlet对象,而SpringMVC框架整个是一个servlet对象,而IOC容器 在Boot框架中,会存放产生servlet容器的工厂,工厂依据主 ...

  2. C# 获取当前服务器运行程序的根目录

    C# 获取当前服务器运行程序的根目录,获取当前运行程序物理路径 string tmpRootDir = AppDomain.CurrentDomain.BaseDirectory;//获得当前服务器程 ...

  3. 如何启动iis(Internet 信息服务(IIS)管理器)

    Internet 信息服务(IIS)管理器 启动 IIS 管理器1.从“开始”菜单,指向“管理工具”,然后单击“Internet 信息服务 (IIS) 管理器”. 从“运行”对话框启动 IIS 管理器 ...

  4. logstash配置文件

    1. 安装  logstash 安装过程很简单,直接参照官方文档: https://www.elastic.co/guide/en/logstash/current/installing-logsta ...

  5. hammer.js方法总结(只做了一个简单的demo)

    html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl ...

  6. Beautiful Paintings CodeForces - 651B (贪心)

    大意: 给定序列$a$, 可以任意排序, 求最大下标i的个数, 满足$a_i<a_{i+1}$. 这个贪心挺好的, 答案就为n-所有数字出现次数最大值.

  7. Bacterial Melee CodeForces - 756D (dp去重)

    大意: 给定字符串, 每次可以任选一个字符$x$, 将$x$左侧或右侧也改为$x$, 求最终能得到多少种字符串. 首先可以观察到最终字符串将连续相同字符合并后一定是原字符串的子序列 并且可以观察到相同 ...

  8. SpringBoot项目Shiro的实现(一)

    一.Shiro的简单介绍 Shiro是Apache下的一个开源项目,我们称之谓Apache Shiro,它是一个易用与Java项目的安全框架,提供了认证.授权.加密.会话管理,与Spring Secu ...

  9. ADG配置(主备库环境)

    @font-face { font-family: "Courier New"; }@font-face { font-family: "宋体"; }@font ...

  10. bootstrap table导出功能无效报错Uncaught INVALID_CHARACTER_ERR: DOM Exception 5和导出中文乱码问题

    由于表格数据中含有中文导致的,在网页的开发者选项中报一个 Uncaught INVALID_CHARACTER_ERR: DOM Exception 5 问题.这个问题是由于BootStrap tab ...