18183游戏网 - 专注分享最好的电脑系统软件!免费安全下载 18183游戏网首页 | Win7激活工具 | 热门专题
18183游戏网> > 系统教程 > 系统安装教程 >

Linux系统中tee命令的具体用法

更新时间:2026-08-21 14:46:10 | 编辑:昔日& | 信息来源:互联网

  Linux下tee命令主要用于将管道导入的数据存成文件,那么tee命令有什么实际应用呢?下面将通过实例来给大家详细介绍下Linux tee命令的用法。

  tee

  功能说明:读取标准输入的数据,并将其内容输出成文件。

  语   法:tee [-ai][--help][--version][文件…]

  补充说明:tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。我们可利用tee把管道导入的数据存成文件,甚至一次保存数份文件。

  参   数:-a 附加到既有文件的后面,而非覆盖它。如果给予tee指令的文件名称已经存在,预设会覆盖该文件的内容。加上此参数后,数据会新增在该文件内容的最后面,而不会删除原先之内容。

  -i 忽略中断信号

  --help 在线帮助

  --version 显示版本信息

  范   例:

  列出文本文件slayers.story的内容,同时复制3份副本,文件名称分别为ss-copy1、ss-copy2、ss-copy3:

  $ cat slayers.story |tee ss-copy1 ss-copy2 ss-copy3

  tee [-ai][--help][--version][文件。。。]

  【功能】

  tee以标准输入作为输入,标准输出和文件作为输出。

  【举例】

  tee file //覆盖

  tee -a file //追加

  tee - //输出到标准输出两次

  tee - - //输出到标准输出三次

  tee file1 file2 - //输出到标准输出两次,并写到那两个文件中

  ls | tee file

  另:把标准错误也被tee读取

  ls “*” 2》&1 | tee ls.txt

  *用tee生成一个文件,包含你敲入的内容:

  代码如下:

  $tee testfile

  这样,会提示要你用标准输入输入内容,然后敲回车会将你输入的内容写入testfile和输出到标准输出,如果用[Ctrl]d结束输入([Ctrl]c也行)。如果原来testfile有内容,将会覆盖。

  *把内容追加到文件的末尾行:

  代码如下:

  $tee -a testfile

  结果类似上,不过如果原来testfile有内容则不会覆盖而是追加。

  *生成一个文件,敲入的时候,不接受中断信号:

  代码如下:

  $tee -i testfile

  结果同testfile,不过不会接收中断信号,只能用[Ctrl]d结束,而不能用[Ctrl]c了。

  *执行ls列出目录文件同时将输出保存到文件test中:

  代码如下:

  $ls | tee test

  这样,会像平时一样执行ls命令并将当前目录的文件名输出到标准输出。另外由于进行了tee命令,所以会生成一个test文件,这个test文件的内容和标准输出的内容一样。

  【描述】

  tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。可以用于既想看到标准输出,又想将标准输出保存到文件中的情况。

  参数:

  -a或--append  附加到既有文件的后面,而非覆盖它.

  -i-i或--ignore-interrupts  忽略中断信号。

  --help  在线帮助。

  --version  显示版本信息。

  常用参数

  格式:tee

  只输出到标准输出,因为没有指定文件嘛。

  格式:tee file

  输出到标准输出的同时,保存到文件file中。如果文件不存在,则创建;如果已经存在,则覆盖之。(If a file being written to does not already exist, it is created. If a file being written to already exists, the data it previously

  contained is overwritten unless the `-a‘ option is used.)

  格式:tee -a file

  输出到标准输出的同时,追加到文件file中。如果文件不存在,则创建;如果已经存在,就在末尾追加内容,而不是覆盖。

  格式:tee -

  输出到标准输出两次。(A FILE of `-’ causes `tee‘ to send another copy of input to standard output, but this is typically not that useful as the copies are interleaved.)

  格式:tee file1 file2 -

  输出到标准输出两次,同时保存到file1和file2中。

  使用示例补充:

  示例一 tee命令与重定向的对比

  [root@web ~]# seq 5 》1.txt

  [root@web ~]# cat 1.txt

  1

  2

  3

  4

  5

  [root@web ~]# cat 1.txt 》2.txt

  [root@web ~]# cat 1.txt | tee 3.txt

  1

  2

  3

  4

  5

  [root@web ~]# cat 2.txt

  1

  2

  3

  4

  5

  [root@web ~]# cat 3.txt

  1

  2

  3

  4

  5

  [root@web ~]# cat 1.txt 》》2.txt

  [root@web ~]# cat 1.txt | tee -a 3.txt

  1

  2

  3

  4

  5

  [root@web ~]# cat 2.txt

  1

  2

  3

  4

  5

  1

  2

  3

  4

  5

  [root@web ~]# cat 3.txt

  1

  2

  3

  4

  5

  1

  2

  3

  4

  5

  [root@web ~]#

  示例二 使用tee命令重复输出字符串

  [root@web ~]# echo 12345 | tee

  12345

  [root@web ~]# echo 12345 | tee -

  12345

  12345

  [root@web ~]# echo 12345 | tee - -

  12345

  12345

  12345

  [root@web ~]# echo 12345 | tee - - -

  12345

  12345

  12345

  12345

  [root@web ~]# echo 12345 | tee - - - -

  12345

  12345

  12345

  12345

  12345

  [root@web ~]#

  [root@web ~]# echo -n 12345 | tee

  12345[root@web ~]# echo -n 12345 | tee -

  1234512345[root@web ~]# echo -n 12345 | tee - -

  123451234512345[root@web ~]# echo -n 12345 | tee - - -

  12345123451234512345[root@web ~]# echo -n 12345 | tee - - - -

  1234512345123451234512345[root@web ~]#

  示例三 使用tee命令把标准错误输出也保存到文件

  [root@web ~]# ls “*”

  ls: *: 没有那个文件或目录

  [root@web ~]# ls “*” | tee -

  ls: *: 没有那个文件或目录

  [root@web ~]# ls “*” | tee ls.txt

  ls: *: 没有那个文件或目录

  [root@web ~]# cat ls.txt

  [root@web ~]# ls “*” 2》&1 | tee ls.txt

  ls: *: 没有那个文件或目录

  [root@web ~]# cat ls.txt

  ls: *: 没有那个文件或目录

  [root@web ~]#

  上面就是Linux下tee命令的用法介绍了,通过实例我们将更好的理解该命令的作用,并灵活用于实际当中,你学会了吗?


返回顶部


18183游戏网发布的系统镜像及软件均来至互联网,仅供学习和研究使用,不得用于任何商业用途并请在下载后24小时内删除,如果满意请联系版权方购买。
如果您发现本站侵害了您的版权,请立即联系我们,本站将第一时间进行相关处理。投诉邮箱1524578900@qq.com
版权声明|联系我们 Copyright © 18183游戏网 All Rights Reserved 鲁ICP备2021038877号-4

2.1962
基本信息
SQL
$_GET
$_POST
$_COOKIE
包含文件
自动加载
  1. 模型: /www/wwwroot/www.pjwan.com/lecms/model/
  2. 视图: /www/wwwroot/www.pjwan.com/view/ww7/xt_show.htm
  3. 控制器: /www/wwwroot/www.pjwan.com/lecms/control/show_control.class.php
  4. 日志目录: /www/wwwroot/www.pjwan.com/log/
  5. 当前页面: /www/wwwroot/www.pjwan.com/index.php
  6. 当前时间: 2026-08-21 14:46:08
  7. 当前网协: 216.73.216.186
  8. 请求路径: /anzhuang/31374.html
  9. 运行时间: 2.1962
  10. 内存开销: 1.33 MB
  1. #0 [time:0.0002s] SELECT * FROM le_runtime WHERE k='cfg' LIMIT 1
  2. #1 [time:0.0002s] SELECT * FROM le_runtime WHERE k='website_group_18183_pjwan_com' LIMIT 1
  3. #2 [time:0.0004s] SELECT * FROM le_runtime WHERE k='cate_68' LIMIT 1
  4. #3 [time:0.0003s] SELECT * FROM le_cms_article WHERE id=31374 LIMIT 1
  5. #4 [time:0.0003s] SELECT * FROM le_user WHERE uid=2 LIMIT 1
  6. #5 [time:0.0002s] SELECT * FROM le_cms_article_data WHERE id=31374 LIMIT 1
  7. #6 [time:0.0002s] SELECT * FROM le_cms_article_views WHERE id=31374 LIMIT 1
  8. #7 [time:0.0003s] UPDATE LOW_PRIORITY le_cms_article_views SET views=views+1 WHERE id=31374 LIMIT 1
  9. #8 [time:0.0002s] SELECT id FROM le_cms_article WHERE id<31374 ORDER BY id DESC LIMIT 0,1
  10. #9 [time:0.0003s] SELECT * FROM le_cms_article WHERE id=31373
  11. #10 [time:0.0002s] SELECT id FROM le_cms_article WHERE id>31374 ORDER BY id ASC LIMIT 0,1
  12. #11 [time:0.0002s] SELECT * FROM le_cms_article WHERE id=31375
  13. #12 [time:0.0003s] SELECT * FROM le_kv WHERE k='navigate' LIMIT 1
  14. #13 [time:0.0002s] SELECT tagid,id FROM le_cms_article_tag_data WHERE tagid=1682 ORDER BY id DESC LIMIT 0,11
  15. #14 [time:0.0003s] SELECT * FROM le_cms_article_tag_data WHERE tagid=1682 AND id=91180 OR tagid=1682 AND id=86113 OR tagid=1682 AND id=85585 OR tagid=1682 AND id=84858 OR tagid=1682 AND id=84853 OR tagid=1682 AND id=84576 OR tagid=1682 AND id=84284 OR tagid=1682 AND id=77383 OR tagid=1682 AND id=76962 OR tagid=1682 AND id=76931 OR tagid=1682 AND id=76871
  16. #15 [time:0.0005s] SELECT * FROM le_cms_article WHERE id=91180 OR id=86113 OR id=85585 OR id=84858 OR id=84853 OR id=84576 OR id=84284 OR id=77383 OR id=76962 OR id=76931
  17. #16 [time:0.0004s] SELECT cid FROM le_category ORDER BY orderby ASC ,cid ASC
  18. #17 [time:0.0016s] SELECT * FROM le_category WHERE cid=1 OR cid=2 OR cid=3 OR cid=4 OR cid=5 OR cid=6 OR cid=7 OR cid=8 OR cid=9 OR cid=10 OR cid=11 OR cid=12 OR cid=13 OR cid=14 OR cid=15 OR cid=16 OR cid=17 OR cid=18 OR cid=19 OR cid=20 OR cid=21 OR cid=22 OR cid=23 OR cid=24 OR cid=25 OR cid=26 OR cid=27 OR cid=28 OR cid=29 OR cid=30 OR cid=31 OR cid=32 OR cid=33 OR cid=34 OR cid=35 OR cid=36 OR cid=37 OR cid=38 OR cid=39 OR cid=40 OR cid=41 OR cid=42 OR cid=43 OR cid=44 OR cid=45 OR cid=46 OR cid=47 OR cid=48 OR cid=49 OR cid=50 OR cid=51 OR cid=52 OR cid=53 OR cid=54 OR cid=55 OR cid=56 OR cid=57 OR cid=58 OR cid=59 OR cid=60 OR cid=61 OR cid=62 OR cid=63 OR cid=64 OR cid=65 OR cid=66 OR cid=67 OR cid=68 OR cid=69 OR cid=70 OR cid=71 OR cid=72 OR cid=73 OR cid=74 OR cid=75 OR cid=76 OR cid=77 OR cid=78 OR cid=79 OR cid=80 OR cid=81 OR cid=82 OR cid=83 OR cid=84 OR cid=85 OR cid=86 OR cid=87 OR cid=88 OR cid=89 OR cid=90 OR cid=91 OR cid=92 OR cid=93 OR cid=94 OR cid=95 OR cid=96 OR cid=97 OR cid=98 OR cid=99 OR cid=100 OR cid=101 OR cid=102 OR cid=103 OR cid=104 OR cid=105 OR cid=106 OR cid=107 OR cid=108 OR cid=109 OR cid=110 OR cid=111 OR cid=112 OR cid=113 OR cid=114 OR cid=115 OR cid=116 OR cid=117 OR cid=118 OR cid=119 OR cid=120 OR cid=121 OR cid=122 OR cid=123 OR cid=124 OR cid=125 OR cid=126 OR cid=127 OR cid=128
  19. #18 [time:0.0002s] SELECT id FROM le_cms_article_views WHERE cid=68 ORDER BY views DESC LIMIT 0,10
  20. #19 [time:0.0005s] SELECT * FROM le_cms_article_views WHERE id=79663 OR id=5640 OR id=79660 OR id=77944 OR id=79665 OR id=79023 OR id=77952 OR id=79666 OR id=79648 OR id=79653
  21. #20 [time:0.0006s] SELECT * FROM le_cms_article WHERE id=79663 OR id=5640 OR id=79660 OR id=77944 OR id=79665 OR id=79023 OR id=77952 OR id=79666 OR id=79648 OR id=79653
  22. #21 [time:0.0002s] SELECT * FROM le_runtime WHERE k='cate_85' LIMIT 1
  23. #22 [time:0.0004s] SELECT id FROM le_cms_win WHERE (cid=86 OR cid=87 OR cid=88 OR cid=89 OR cid=90 OR cid=91 OR cid=92 OR cid=93 OR cid=94 OR cid=95 OR cid=96 OR cid=97 OR cid=98 OR cid=99 OR cid=100) ORDER BY id DESC LIMIT 0,10
  24. #23 [time:0.0004s] SELECT * FROM le_cms_win WHERE id=1027 OR id=1026 OR id=1025 OR id=1024 OR id=1023 OR id=1022 OR id=1021 OR id=1020 OR id=1019 OR id=1018
  25. #24 [time:0.0002s] SELECT * FROM le_runtime WHERE k='cate_64' LIMIT 1
  26. #25 [time:0.0005s] SELECT id FROM le_cms_article WHERE (cid=65 OR cid=66 OR cid=67 OR cid=68 OR cid=125 OR cid=126 OR cid=127 OR cid=128) ORDER BY id DESC LIMIT 0,10
  27. #26 [time:0.0005s] SELECT * FROM le_cms_article WHERE id=103563 OR id=103562 OR id=103561 OR id=103560 OR id=103559 OR id=103558 OR id=103557 OR id=103556 OR id=103555 OR id=103554
  1. #control => show
  2. #action => index
  3. #cid => 68
  4. #id => 31374
  5. #mid => 2
    1. #cdn_sec_tc => 0819529e17872947201686706edbe8adcff10fc4a1d49965c39bb5cc4e
    2. #acw_tc => 0819529e17872947201686706edbe8adcff10fc4a1d49965c39bb5cc4e
    3. #PHPSESSID => 4anmn9tbuvekthfupovl6ob11i
    1. #0 /www/wwwroot/www.pjwan.com/index.php
    2. #1 /www/wwwroot/www.pjwan.com/lecms/xiunophp/xiunophp.php
    3. #2 /www/wwwroot/www.pjwan.com/lecms/config/config.inc.php
    4. #3 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/base.func.php
    5. #4 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/core.class.php
    6. #5 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/debug.class.php
    7. #6 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/log.class.php
    8. #7 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/model.class.php
    9. #8 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/view.class.php
    10. #9 /www/wwwroot/www.pjwan.com/lecms/xiunophp/lib/control.class.php
    11. #10 /www/wwwroot/www.pjwan.com/lecms/xiunophp/db/db.interface.php
    12. #11 /www/wwwroot/www.pjwan.com/lecms/xiunophp/db/db_pdo_mysql.class.php
    13. #12 /www/wwwroot/www.pjwan.com/lecms/xiunophp/cache/cache.interface.php
    14. #13 /www/wwwroot/www.pjwan.com/lecms/xiunophp/cache/cache_memcache.class.php
    15. #14 /www/wwwroot/www.pjwan.com/lecms/xiunophp/ext/network/Network__interface.php
    16. #15 /www/wwwroot/www.pjwan.com/lecms/config/plugin.inc.php
    17. #16 /www/wwwroot/www.pjwan.com/lecms/plugin/editor_sd/conf.php
    18. #17 /www/wwwroot/www.pjwan.com/lecms/plugin/editor_tinymce/conf.php
    19. #18 /www/wwwroot/www.pjwan.com/lecms/plugin/editor_um/conf.php
    20. #19 /www/wwwroot/www.pjwan.com/lecms/plugin/le_adminer/conf.php
    21. #20 /www/wwwroot/www.pjwan.com/lecms/plugin/le_baidu_zz/conf.php
    22. #21 /www/wwwroot/www.pjwan.com/lecms/plugin/le_category_filter/conf.php
    23. #22 /www/wwwroot/www.pjwan.com/lecms/plugin/le_content_tag_url/conf.php
    24. #23 /www/wwwroot/www.pjwan.com/lecms/plugin/le_data_table_split/conf.php
    25. #24 /www/wwwroot/www.pjwan.com/lecms/plugin/le_drafts/conf.php
    26. #25 /www/wwwroot/www.pjwan.com/lecms/plugin/le_feedback/conf.php
    27. #26 /www/wwwroot/www.pjwan.com/lecms/plugin/le_homepage_feign/conf.php
    28. #27 /www/wwwroot/www.pjwan.com/lecms/plugin/le_html_cache/conf.php
    29. #28 /www/wwwroot/www.pjwan.com/lecms/plugin/le_links/conf.php
    30. #29 /www/wwwroot/www.pjwan.com/lecms/plugin/le_minganci_do/conf.php
    31. #30 /www/wwwroot/www.pjwan.com/lecms/plugin/le_rand404content/conf.php
    32. #31 /www/wwwroot/www.pjwan.com/lecms/plugin/le_rand_author/conf.php
    33. #32 /www/wwwroot/www.pjwan.com/lecms/plugin/le_rand_pic_cid/conf.php
    34. #33 /www/wwwroot/www.pjwan.com/lecms/plugin/le_sharejs/conf.php
    35. #34 /www/wwwroot/www.pjwan.com/lecms/plugin/le_slide/conf.php
    36. #35 /www/wwwroot/www.pjwan.com/lecms/plugin/le_special_pro/conf.php
    37. #36 /www/wwwroot/www.pjwan.com/lecms/plugin/le_spider/conf.php
    38. #37 /www/wwwroot/www.pjwan.com/lecms/plugin/le_super_sitemap/conf.php
    39. #38 /www/wwwroot/www.pjwan.com/lecms/plugin/le_title_pic/conf.php
    40. #39 /www/wwwroot/www.pjwan.com/lecms/plugin/le_use_del_id/conf.php
    41. #40 /www/wwwroot/www.pjwan.com/lecms/plugin/le_webp_oss/conf.php
    42. #41 /www/wwwroot/www.pjwan.com/lecms/plugin/le_website_group/conf.php
    43. #42 /www/wwwroot/www.pjwan.com/lecms/plugin/le_zhanqunsitemaps_pro_v303/conf.php
    44. #43 /www/wwwroot/www.pjwan.com/lecms/plugin/lu_huochetou/conf.php
    45. #44 /www/wwwroot/www.pjwan.com/lecms/plugin/models_filed/conf.php
    46. #45 /www/wwwroot/www.pjwan.com/lecms/plugin/qrcode/conf.php
    47. #46 /www/wwwroot/www.pjwan.com/lecms/plugin/sy_mobile/conf.php
    48. #47 /www/wwwroot/www.pjwan.com/runcache/misc.func.php
    49. #48 /www/wwwroot/www.pjwan.com/runcache/core_lang/zh-cn.php
    50. #49 /www/wwwroot/www.pjwan.com/runcache/lang/zh-cn.php
    51. #50 /www/wwwroot/www.pjwan.com/runcache/lecms_control/parseurl_control.class.php
    52. #51 /www/wwwroot/www.pjwan.com/runcache/lecms_model/runtime_model.class.php
    53. #52 /www/wwwroot/www.pjwan.com/runcache/lecms_control/show_control.class.php
    54. #53 /www/wwwroot/www.pjwan.com/runcache/lecms_control/base_control.class.php
    55. #54 /www/wwwroot/www.pjwan.com/runcache/lecms_model/urls_model.class.php
    56. #55 /www/wwwroot/www.pjwan.com/runcache/lecms_model/category_model.class.php
    57. #56 /www/wwwroot/www.pjwan.com/runcache/lecms_model/cms_content_model.class.php
    58. #57 /www/wwwroot/www.pjwan.com/runcache/lecms_view/ww7,xt_show.htm.php
    59. #58 /www/wwwroot/www.pjwan.com/runcache/lecms_model/cms_content_data_model.class.php
    60. #59 /www/wwwroot/www.pjwan.com/runcache/lecms_model/cms_content_tag_model.class.php
    61. #60 /www/wwwroot/www.pjwan.com/runcache/lecms_model/user_model.class.php
    62. #61 /www/wwwroot/www.pjwan.com/runcache/lecms_model/cms_content_views_model.class.php
    63. #62 /www/wwwroot/www.pjwan.com/runcache/lecms_model/kv_model.class.php
    64. #63 /www/wwwroot/www.pjwan.com/runcache/lecms_model/cms_content_tag_data_model.class.php
    65. #64 /www/wwwroot/www.pjwan.com/lecms/xiunophp/tpl/sys_trace.php