zoukankan      html  css  js  c++  java
  • linux中的tail以及unzip命令的简单使用

    linux 中的 tail 命令

    tail 命令可用于查看文件的内容,有一个常用的参数 -f 常用于查阅正在改变的日志文件。

    tail -f filename 会把 filename 文件里的最尾部的内容显示在屏幕上,并且不断刷新,只要 filename 更新就可以看到最新的文件内容。

    命令格式:

    tail [参数] [文件]  
    

    参数:

    • -f 循环读取
    • -q 不显示处理信息
    • -v 显示详细的处理信息
    • -c<数目> 显示的字节数
    • -n<行数> 显示文件的尾部 n 行内容
    • --pid=PID 与-f合用,表示在进程ID,PID死掉之后结束
    • -q, --quiet, --silent 从不输出给出文件名的首部
    • -s, --sleep-interval=S 与-f合用,表示在每次反复的间隔休眠S秒

    实例

    要显示 notes.log 文件的最后 10 行,请输入以下命令:

    tail notes.log
    

    要跟踪名为 notes.log 的文件的增长情况,请输入以下命令:

    tail -f notes.log
    

    此命令显示 notes.log 文件的最后 10 行。当将某些行添加至 notes.log 文件时,tail 命令会继续显示这些行。 显示一直继续,直到您按下(Ctrl-C)组合键停止显示。

    显示文件 notes.log 的内容,从第 20 行至文件末尾:

    tail -n +20 notes.log
    

    显示文件 notes.log 的最后 10 个字符:

    tail -c 10 notes.log
    

    linux 中的 unzip 简单使用

    1、把文件解压到当前目录下

    unzip test.zip
    

    2、如果要把文件解压到指定的目录下,需要用到-d参数。

    unzip -d /temp test.zip
    

    3、解压的时候,有时候不想覆盖已经存在的文件,那么可以加上-n参数

    unzip -n test.zip
    unzip -n -d /temp test.zip
    

    4、只看一下zip压缩包中包含哪些文件,不进行解压缩

    unzip -l test.zip
    

    5、查看显示的文件列表还包含压缩比率

    unzip -v test.zip
    

    6、检查zip文件是否损坏

    unzip -t test.zip
    

    7、将压缩文件test.zip在指定目录tmp下解压缩,如果已有相同的文件存在,要求unzip命令覆盖原先的文件

    unzip -o test.zip -d /tmp/
    
    抟扶摇而上者九万里
  • 相关阅读:
    React方法论
    React学习记录
    LeetCode 530. Minimum Absolute Difference in BST
    LeetCode 521. Longest Uncommon Subsequence I
    LeetCode 520. Detect Capital
    LeetCode 516. Longest Palindromic Subsequence
    LeetCode 513. Find Bottom Left Tree Value
    LeetCode 506. Relative Ranks
    LeetCode 504. Base 7
    LeetCode 500. Keyboard Row
  • 原文地址:https://www.cnblogs.com/fengting0913/p/14311809.html
Copyright © 2011-2022 走看看