linux 常用操作命令:2

简单点说,grep是查找匹配条件的行,find是搜索匹配条件的文件。

ct@ubuntu:~/Desktop/mydriver$ grep -nr ./"include"

结果: 在当前目录下显示行    r -- 递归  n---行数  ---i 查找时忽略大小写   -H或--with-filename 在显示符合范本样式的那一列之前,表示该列所属的文件名称。

.led.o.cmd:34:  arch/x86/include/asm/posix_types.h \
.led.o.cmd:36:  arch/x86/include/uapi/asm/posix_types_32.h \
.led.o.cmd:72:  /usr/lib/gcc/i686-linux-gnu/4.8/include/stdarg.h \

ct@ubuntu:~/Desktop/mydriver$ grep -rn "open" . --include=*.c

结果:     . --include=*.c  -----当前目录下的 c文件中

./led_app.c:11:    int fd = open("/dev/led", O_RDWR|O_CREAT);
./led_app.c:13:    printf("/dev/led open %d\n",fd);
./led_app.c:16:        printf("/dev/hello open fail \n");

./led.c:17:int led_drv_open(struct inode * node, struct file* h_fl)


ct@ubuntu:~$ find . -type f -name "*.c" | xargs grep "return"

结果:find . 当前目录  -type f 文件类型 f普通文件  xargs  递归查找    目标字符可带*等符号  可不带引号

./Desktop/quelink.c:    return ( (ql->head==ql->rear)&&(ql->head==ql->front) );
./Desktop/quelink.c:            return;
ct@ubuntu:~$ find . -name '*.c' -exec grep -l "include" {} \;

结果:  exec选项后面跟随着所要执行的命令或脚本,然后是一对儿 {},一个空格和一个\,最后是一个分号。     cmd {} \;

参数后面跟的是command命令,它的终止是以;为结束标志的,所以这句命令后面的分号是不可缺少的,考虑到各个系统中分号会有不同的意义,所以前面加反斜杠。
{} 花括号代表前面find查找出来的文件名

./Desktop/quelink.c

./Desktop/chain.c
./Desktop/test.c







工作中采用的 linux 命令 ........................................................................................................ 3 1.从其他机器拷贝文件夹 ........................................................................................................ 3 2.查看哪个程序在用特定端口 ................................................................................................ 3 3.实时监控日志文件内容 ........................................................................................................ 3 4.查看指定用户拥有的进程 .................................................................................................... 3 5.查看磁盘空间使用情况 ........................................................................................................ 3 6.查找某文件中出现指定字符串的行 .................................................................................... 3 7.查看内存使用情况 ................................................................................................................ 4 8.查看本机系统内核 ................................................................................................................ 4 9.查看当前路径下的文件/文件夹大小 ................................................................................... 4 10.变更为其它使用者的身份 .................................................................................................. 4 11.远程登陆 .............................................................................................................................. 4 12.不挂断地运行命令 .............................................................................................................. 4 13.查看文件的行数 .................................................................................................................. 4 14.比较两个文件的不同之处 .................................................................................................. 4 15.杀死进程 .............................................................................................................................. 5 16.在 SecureCRT 中把文件传给本机的 SecureCRT 安装目录的 download 目录下 ............ 5 17.把本机文件传给 SecureCRT 中当前机器的当前目录 ...................................................... 5 18.Vi 文本编辑器 ..................................................................................................................... 5 19.察看文件类型 ...................................................................................................................... 6 20.文本抽取 .............................................................................................................................. 6 21.非交互性文本流编辑器 ...................................................................................................... 7 22.将文件中的记录分类 .......................................................................................................... 7 23.去除文本文件的重复行 ...................................................................................................... 7 24.连接两个文本文件 .............................................................................................................. 8 25.从文本文件中剪切列或域 .................................................................................................. 8 26.将两个文本文件粘贴在一起 .............................................................................................. 8 27.将大文件进行分割 .............................................................................................................. 9 二.linux 常用命令 ............................................................................................................................ 9 1. cd ........................................................................................................................................... 9 2. pwd ........................................................................................................................................ 9 3. ls ............................................................................................................................................ 9 4. passwd ................................................................................................................................. 10 5. who ...................................................................................................................................... 11 6. cat ........................................................................................................................................ 11 7. mkdir ................................................................................................................................... 12 8. rmdir .................................................................................................................................... 12 9. chmod .................................................................................................................................. 12 10. chown ................................................................................................................................ 13 11. chgrp .................................................................................................................................. 13 12. touch .................................................................................................................................. 14 13. cp ....................................................................................................................................... 15 14. mv ..................................................................................................................................... 15 15. rm ...................................................................................................................................... 15 16. find .................................................................................................................................... 16 17. grep ................................................................................................................................... 16 18. more .................................................................................................................................. 17 19. less..................................................................................................................................... 17 20. head ................................................................................................................................... 17 21. tail ..................................................................................................................................... 18 22. cut ...................................................................................................................................... 18 23. at ........................................................................................................................................ 18 24. crontab ............................................................................................................................... 19 25. sleep .................................................................................................................................. 20 26. mesg .................................................................................................................................. 20 27. wall .................................................................................................................................... 20 28. write .................................................................................................................................. 21 29. kill ..................................................................................................................................... 21 30. ps ....................................................................................................................................... 21 31. pstree ................................................................................................................................. 22 32. top ..................................................................................................................................... 23 33. expr ................................................................................................................................... 23 34. locate ................................................................................................................................. 24 35. split .................................................................................................................................... 24 36. ln ....................................................................................................................................... 25 37. login 、logout .................................................................................................................. 25 38. exit ..................................................................................................................................... 25 39. man,info ......................................................................................................................... 25 40. alias ................................................................................................................................... 26 41. unalias ............................................................................................................................... 26 42. halt ..................................................................................................................................... 26 43. shutdown ........................................................................................................................... 26 44. reboot ................................................................................................................................ 26 45. clear ................................................................................................................................... 26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值