您的位置:首页 > 运维架构 > Shell

[linux shell]:实用小技巧--获取文本文档的行数

2012-05-28 10:59 239 查看
假设:现在有一个test文件,共有100行

  第一种:

  # awk '{print NR}' test|tail -n1
  100

  第二种:

  # awk 'END{print NR}' test
  55

  第三种:

  # grep -n "" test|awk -F: '{print '}|tail -n1
          100

  第四种:

  # sed -n '$=' test
  100

  第五种:

  # wc -l test|awk '{print }'
       100

  第六种:

  #cat test |wc -l

         100
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell linux 文档