前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >LPI学习笔记 -----2

LPI学习笔记 -----2

作者头像
用户3765803
发布2019-03-05 09:56:55
5430
发布2019-03-05 09:56:55
举报
文章被收录于专栏:悟空被FFmpeg玩

正顺序读一个文件和反顺序读一个文件

  1. [root@btg vim_plugin_config]# cat README
  2. This tarball is autoconfig vim ,
  3. it can install some config file
  4. and plugin file in to your vim
  5. [root@btg vim_plugin_config]# tac README
  6. and plugin file in to your vim
  7. it can install some config file
  8. This tarball is autoconfig vim ,
  9. [root@btg vim_plugin_config]#

读取文件末尾处的内容

tail -n默认读取末尾十行的内容

tail -n 可以指定读末尾指定行数的内容

  1. [root@btg ~]# tail a
  2. <6>[ 31.625063] [audpp.c:audpp_dsp_event] DISABLE
  3. <6>[ 31.626963] [audpp.c:audpp_disable] Received CFG_MSG_DISABLE from ADSP
  4. <6>[ 31.626986] [adsp.c:msm_adsp_disable] disable 'AUDPPTASK'
  5. <6>[ 31.629338] [adsp.c:msm_adsp_put] closing module AUDPPTASK
  6. <6>[ 31.629381] [audmgr.c:audmgr_disable] session 0xc070cfa0
  7. <6>[ 31.631244] [audmgr.c:audmgr_rpc_thread] rpc_reply status 0
  8. <3>[ 31.640831] [audmgr.c:process_audmgr_callback] DISABLED
  9. <6>[ 31.971498] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  10. <6>[ 32.052659] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  11. <6>[ 32.086464] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  12. [root@btg ~]# tail -n 15 a
  13. <7>[ 24.038064] BATT: voltage = 4200 mV [capacity = 100%]
  14. <6>[ 27.021079] [snd.c:snd_ioctl] snd_set_volume 31 0 6
  15. <6>[ 27.479176] [xsensor] als_power_ctl val = 1
  16. <6>[ 27.594288] request_suspend_state: wakeup (3->0) at 27593166742 (2011-05-16 10:40:30.217523356 UTC)
  17. <4>[ 27.728714] gsensor_enable_store 1
  18. <6>[ 31.625063] [audpp.c:audpp_dsp_event] DISABLE
  19. <6>[ 31.626963] [audpp.c:audpp_disable] Received CFG_MSG_DISABLE from ADSP
  20. <6>[ 31.626986] [adsp.c:msm_adsp_disable] disable 'AUDPPTASK'
  21. <6>[ 31.629338] [adsp.c:msm_adsp_put] closing module AUDPPTASK
  22. <6>[ 31.629381] [audmgr.c:audmgr_disable] session 0xc070cfa0
  23. <6>[ 31.631244] [audmgr.c:audmgr_rpc_thread] rpc_reply status 0
  24. <3>[ 31.640831] [audmgr.c:process_audmgr_callback] DISABLED
  25. <6>[ 31.971498] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  26. <6>[ 32.052659] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  27. <6>[ 32.086464] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  28. [root@btg ~]# tail -n 1 a
  29. <6>[ 32.086464] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  30. [root@btg ~]# tail -f a
  31. <6>[ 31.625063] [audpp.c:audpp_dsp_event] DISABLE
  32. <6>[ 31.626963] [audpp.c:audpp_disable] Received CFG_MSG_DISABLE from ADSP
  33. <6>[ 31.626986] [adsp.c:msm_adsp_disable] disable 'AUDPPTASK'
  34. <6>[ 31.629338] [adsp.c:msm_adsp_put] closing module AUDPPTASK
  35. <6>[ 31.629381] [audmgr.c:audmgr_disable] session 0xc070cfa0
  36. <6>[ 31.631244] [audmgr.c:audmgr_rpc_thread] rpc_reply status 0
  37. <3>[ 31.640831] [audmgr.c:process_audmgr_callback] DISABLED
  38. <6>[ 31.971498] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  39. <6>[ 32.052659] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  40. <6>[ 32.086464] binder: 70:70 BC_REQUEST_DEATH_NOTIFICATION death notification already set
  41. test for tail command
  42. ^C
  43. [root@btg ~]#

tail -f,读取文件末尾的内容,并且实时获得文件末尾新增加的内容

tr用来作字符转换

  1. [root@btg ~]# cat README |tr a-z A-Z
  2. THIS TARBALL IS AUTOCONFIG VIM ,
  3. IT CAN INSTALL SOME CONFIG FILE
  4. AND PLUGIN FILE IN TO YOUR VIM
  5. [root@btg ~]# cat README |tr c K
  6. This tarball is autoKonfig vim ,
  7. it Kan install some Konfig file
  8. and plugin file in to your vim
  9. [root@btg ~]# cat README |tr \ 0
  10. This0tarball0is0autoconfig0vim0,0
  11. it0can0install0some0config0file0
  12. and0plugin0file0in0to0your0vim
  13. [root@btg ~]#

tr删除字符

  1. [root@btg ~]# cat README |tr -d c
  2. This tarball is autoonfig vim ,
  3. it an install some onfig file
  4. and plugin file in to your vim
  5. [root@btg ~]#
  6. [root@btg ~]#
  7. [root@btg ~]# cat README |tr -d abc
  8. This trll is utoonfig vim ,
  9. it n instll some onfig file
  10. nd plugin file in to your vim

显示文本内容处理,文本内容排序处理

  1. [root@btg ~]# cat testfile
  2. aaaaaa
  3. bbbbbb
  4. cccccc
  5. dddddd
  6. eeeeee
  7. aaaaaa
  8. bbbbbb
  9. cccccc
  10. cccccc
  11. dddddd
  12. eeeeee
  13. aaaaaa
  14. [root@btg ~]# uniq -d testfile
  15. cccccc
  16. [root@btg ~]# uniq -u testfile
  17. aaaaaa
  18. bbbbbb
  19. cccccc
  20. dddddd
  21. eeeeee
  22. aaaaaa
  23. bbbbbb
  24. dddddd
  25. eeeeee
  26. aaaaaa
  27. [root@btg ~]# sort testfile |uniq
  28. aaaaaa
  29. bbbbbb
  30. cccccc
  31. dddddd
  32. eeeeee
  33. [root@btg ~]# sort testfile |uniq -d
  34. aaaaaa
  35. bbbbbb
  36. cccccc
  37. dddddd
  38. eeeeee
  39. [root@btg ~]#

wc查看文件大小,内容多少

  1. [root@btg ~]# wc -l testfile
  2. 12 testfile
  3. [root@btg ~]# wc -c testfile
  4. 84 testfile
  5. [root@btg ~]# wc -w testfile
  6. 12 testfile
  7. [root@btg ~]# cat testfile
  8. aaaaaa
  9. bbbbbb
  10. cccccc
  11. dddddd
  12. eeeeee
  13. aaaaaa
  14. bbbbbb
  15. cccccc
  16. cccccc
  17. dddddd
  18. eeeeee
  19. aaaaaa
  20. [root@btg ~]#
  21. [root@btg ~]# cat -n testfile
  22.      1    aaaaaa
  23.      2    bbbbbb
  24.      3    cccccc
  25.      4    dddddd
  26.      5    eeeeee
  27.      6    aaaaaa
  28.      7    bbbbbb
  29.      8    cccccc
  30.      9    cccccc
  31.     10    dddddd
  32.     11    eeeeee
  33.     12    aaaaaa
  34. [root@btg ~]#
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2011/05/27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档