Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2345482
  • 博文数量: 141
  • 博客积分: 3552
  • 博客等级: 中校
  • 技术积分: 4148
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-15 14:39
个人简介

熟悉Linux下程序设计及各种应用程序 熟悉C Language 熟悉Glusterfs、FFmpeg、CDN 系统设计,计算机图形系统设计、分布式程序设计 目前主要研究方向:流媒体

文章分类

全部博文(141)

分类: LINUX

2011-05-27 15:12:06

正顺序读一个文件和反顺序读一个文件
  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 ~]#










阅读(3963) | 评论(0) | 转发(0) |
0

上一篇:LPI学习笔记----1

下一篇:linux到3.0了

给主人留下些什么吧!~~