wc命令

作用:统计文件的字节,单词,行数

用法:wc [option] [file]

-c:统计字节

ghostwu@dev:~/linux/uniq$ cat ghostwu.txt
192.168.1.2
192.168.1.8
192.168.1.3
192.168.1.3
192.168.1.9
192.168.1.8
192.168.1.8
192.168.1.0
192.168.1.3
ghostwu@dev:~/linux/uniq$ wc -c ghostwu.txt
ghostwu.txt
ghostwu@dev:~/linux/uniq$ ls -lh
total .0K
-rw-rw-r-- ghostwu ghostwu 5月 : ghostwu.txt

-l : 统计行数:

ghostwu@dev:~/linux/uniq$ cat -n ghostwu.txt
192.168.1.2
192.168.1.8
192.168.1.3
192.168.1.3 192.168.1.9
192.168.1.8
192.168.1.8
192.168.1.0
192.168.1.3
ghostwu@dev:~/linux/uniq$ wc -l ghostwu.txt
ghostwu.txt

-m: 统计字符

ghostwu@dev:~/linux/uniq$ cat char.txt
hello,my name is ghostwu
ghostwu@dev:~/linux/uniq$ wc -m char.txt
char.txt

-c: 统计字节

ghostwu@dev:~/linux/uniq$ wc -c char.txt
char.txt

-c与-m的区别,"你好啊" 是3个字符,占用9个字节。一般情况下,一个中文在utf8编码下,占用3个字节

ghostwu@dev:~/linux/uniq$ wc -m char.txt
char.txt
ghostwu@dev:~/linux/uniq$ wc -c char.txt
char.txt
ghostwu@dev:~/linux/uniq$ cat char.txt
hello,my name is ghostwu
你好啊

-w: 统计单词,空格隔开才算一个单词

ghostwu@dev:~/linux/uniq$ cat char.txt
hello,my name is ghostwu
你好啊
ghostwu@dev:~/linux/uniq$ vim char.txt
ghostwu@dev:~/linux/uniq$ wc -w char.txt
char.txt
ghostwu@dev:~/linux/uniq$ vim char.txt
ghostwu@dev:~/linux/uniq$ cat char.txt
hello my name is ghostwu
你 好 啊
ghostwu@dev:~/linux/uniq$ wc -w char.txt
char.txt

-L:打印最长行的长度

ghostwu@dev:~/linux/uniq$ wc -L char.txt
char.txt

Linux常用基本命令wc-统计文件的字节,字符,行数的更多相关文章

  1. linux常用命令 wc统计命令

    统计命令wc wc [选项] 文件名 选项 -l 只统计行数 -w 只统计单词数 -m 只统计字符数 192:linux_worspace aouo$ wc /etc/passwd     103   ...

  2. Linux统计文件个数或是代码行数

    统计指定后缀名的文件总个数命令: find . -name *.cpp | wc -l 统计一个目录下代码总行数以及单个文件行数: find . -name *.h | xargs wc -l lin ...

  3. 利用fgetc统计文件所在字节 和 总行数 和单词数

    #include <stdio.h> #include <stdlib.h> #define IS_WHITE_SPACE(c) ((c)==' '||(c)=='\t'||( ...

  4. Linux - wc统计文件行数、单词数或字节数

    一 wc简单介绍 wc命令用来打印文件的文本行数.单词数.字节数等(print the number of newlines, words, and bytes in files).在Windows的 ...

  5. Linux常用基本命令(less)

    转: Linux常用基本命令(less) LESS:跟more命令的功能类似,都是用于分页显示内容,但是他的性能比more更高,功能比more更丰富,他读取文件是按需加载 格式: less [opti ...

  6. Linux 常用基本命令及应用技巧

    需要pdf 版 联系我 我的文件中有目录一.Linux 的常用基本命令................................................................. ...

  7. wc 统计文件的行数

    1.命令功能 wc 统计文件的行数,单词和字节数 2.语法格式 wc  option  file wc  option  --files0-from=F 参数说明 参数 参数说明 -c 统计字节数 - ...

  8. 【原】Mac下统计任意文件夹中代码行数的工

    [链接][原]Mac下统计任意文件夹中代码行数的工http://www.cnblogs.com/wengzilin/p/4580646.html

  9. Java笔记13:统计文件中每个字符出现的次数

    一.代码实现 import java.io.*; import java.util.*; /** 功能:统计文件中每个字符出现的次数 思路: 1.定义字符读取(缓冲)流 2.循环读取文件里的字符,用一 ...

随机推荐

  1. 14_python 匿名函数,递归函数

    一.匿名函数 语法: 函数名 = lambda 参数: 返回值    # lambda x,y,z=1:x+y+z 注意: 1.函数的参数可以有多个. 多个参数之间⽤逗号隔开  2.匿名函数不管多复杂 ...

  2. elasticsearch插件一head插件安装详解

    elasticsearch-head是一个用来浏览.与Elastic Search簇进行交互的web前端展示插件. elasticsearch-head插件主要用途: elasticsearch主要有 ...

  3. [Vue] vue-cli3.0安装

    1. node.js安装https://nodejs.org/en/download/ 2.npm的安装 由于新版的nodejs已经集成了npm,所以之前npm也一并安装好了.同样可以通过输入 &qu ...

  4. iOS数据持久化--归档

    一.简介 在使用plist进行数据存储和读取,只适用于系统自带的一些常用类型才能用,且必须先获取路径相对麻烦: 偏好设置(将所有的东西都保存在同一个文件夹下面,且主要用于存储应用的设置信息 归档:因为 ...

  5. python面试(3)

    一.语言 推荐一本看过最好的python书籍? 拉开话题好扯淡 谈谈python的装饰器,迭代器,yield? 标准库线程安全的队列是哪一个?不安全的是哪一个?logging是线程安全的吗? pyth ...

  6. webgl之五彩光源

    一.Three.js中有哪些光源? 在Three.js中,光源有一个基类THREE.Light(hex),这个hex接受16进制颜色作为参数而初始化光源的颜色,比如我们要定义一种绿色的光源,可以这样来 ...

  7. flex布局中transform出错

    在flex布局下,若应用transform 的动画的子元素没有使用进行定位,则动画过程中,子元素将相对display:flex的元素进行static定位 动画结束后位置正常: 修复代码只需要posit ...

  8. SqlServer 查看被锁的表和解除被锁的表

    查看被锁的表 1 2 select   request_session_id   spid,OBJECT_NAME(resource_associated_entity_id) tableName   ...

  9. android app性能优化大汇总(google官方Android性能优化典范 - 第3季)

    (1)Fun with ArrayMaps 程序内存的管理是否合理高效对应用的性能有着很大的影响,有的时候对容器的使用不当也会导致内存管理效率低下.Android为移动操作系统特意编写了一些更加高效的 ...

  10. Linux 数据重定向

    名称 描述 代码 表示 stdin 标准输入 0 < 或 << stdout 标准输出 1 > 或 >> stderr 标准错误输出 2 2> 或 2> ...