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. [Spring] 04 Denpendency Injection

    DI Dependency Injection 依赖注入:从程序代码中移除依赖关系的一种设计模式. 这样就可以更容易地管理和测试应用程序. DI使我们的程序编码 loosely coupled.松耦合 ...

  2. 20165303学习基础和C语言基础调查

    20165303学习基础和C语言基础调查 技能学习心得 我认为我的乒乓球打的还不错,不能说非常好,但是基本的一些技巧都还是会的,小时候爸爸就非常爱看乒乓球比赛,有时候也带着我一起看,最开始看的时候我发 ...

  3. LeetCode--383--赎金信

    问题描述: 给定一个赎金信 (ransom) 字符串和一个杂志(magazine)字符串,判断第一个字符串ransom能不能由第二个字符串magazines里面的字符构成.如果可以构成,返回 true ...

  4. hihocoder-1419 后缀数组四·重复旋律4 求连续重复次数最多的子串

    对于重复次数,如果确定了重复子串的长度len,那重复次数k=lcp(start,start+len)/len+1.而暴力枚举start和len的复杂度是O(n^2),不能接受.而有一个规律,若我们只枚 ...

  5. NYOJ - 整数划分(四)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=746 要求对一个n的整数插入m个乘号,求最大结果. 构造dp:dp[i][j]表示枚举至j ...

  6. Lua常用封装方法

    Lua 获取随机值 --获取随机值,指定上限和下限 function getRandom(min,max) -- 接收一个整数n作为随即序列的种子 math.randomseed(os.time()) ...

  7. Tree Requests CodeForces - 570D (dfs水题)

    大意: 给定树, 每个节点有一个字母, 每次询问子树$x$内, 所有深度为$h$的结点是否能重排后构成回文. 直接暴力对每个高度建一棵线段树, 查询的时候相当于求子树内异或和, 复杂度$O((n+m) ...

  8. IDEA能运行,但是出现红色下划线的问题报 cannot resolve method

    能编译通过并运行说明SDK导入正确,但是为啥我们点击每一个Java文件会出现好多红色的下划线 ,并提示idea cant resolve symbol.原因就是可能没有清除原来的历史缓存,导致一些错误 ...

  9. Oracle11g温习-第十三章:索引

    2013年4月27日 星期六 10:46 1.索引(Index)的功能:对记录进行排序,加快表的查询速度  2.索引的分类  1)B-tree 索引(默认) a.在一个大表上 b.建立在重复值比较少的 ...

  10. python 小练习4

    给你一个整数list L, 如 L=[2,-3,3,50], 求L的一个连续子序列,使其和最大,输出最大子序列的和. 例如,对于L=[2,-3,3,50], 输出53(分析:很明显,该列表最大连续子序 ...