Shell/Bash在线运行

运行结果
教程手册
代码仓库
极速运行
终端运行
图形+终端

                        
以下是用户最新保存的代码
查询被封禁ip 发布于:2023-09-19 16:37 shell减法函数 发布于:2023-09-13 10:57 centos7测试tomcat服务是否正常运行 发布于:2023-09-13 10:25 shell-study 发布于:2023-09-06 15:06 just for shell script learn 发布于:2023-09-01 09:34 测试Shell参数传递 发布于:2023-08-24 11:27 对cdh6进行自动化安装 发布于:2023-08-23 10:10 安装zookeeper 发布于:2023-08-14 18:32 安装mongo 发布于:2023-08-11 17:40 容器安装mysql 发布于:2023-08-04 15:19 最后的最后把它搞定 发布于:2023-08-03 14:32 shell测试 发布于:2023-08-01 16:07 Shell 代码验证 发布于:2023-07-24 15:25 shell测试程序 发布于:2023-07-23 22:31 在 bash 中运行简单正确的 C 发布于:2023-07-23 10:55 shell函数5-4 while循环 发布于:2023-07-20 10:56 shell的demo 发布于:2023-07-17 23:14 # linux 初学者 发布于:2023-08-24 15:02 shell 在线脚本 1 发布于:2023-07-12 22:16 简单的计算器实现 发布于:2023-07-11 17:17 手机号码正则验证 发布于:2023-08-07 16:20 指定关闭或打开端口号 发布于:2023-07-07 16:14 #!/bin/bash a="hello,world,nice,to,meet,you" #要将$a分割开,先存储旧的分隔符 OLD_IFS="$IFS" #设置分隔符 IFS="," #如下会自动分隔 arr=($a) #恢复原来的分隔符 IFS="$OLD_IFS" function func1(){ echo $@ } #遍历数组 for s in ${arr[@]} do func1 "$s" done echo "完成" 发布于:2023-07-04 14:17 批量增加用户打印 发布于:2023-06-12 13:41 ##10num求最值平均值 发布于:2023-06-12 16:12 测试Jenkins 发布于:2023-06-07 14:02 九九乘法表 发布于:2023-06-07 10:37 case判断 发布于:2023-06-07 10:13 这是一个测试代码 发布于:2023-06-07 09:25 测试shell 发布于:2023-05-29 18:53 ## shell流程控制语句 发布于:2023-05-29 14:46 shell函数 发布于:2023-05-29 11:32 prinf格式化 发布于:2023-05-29 11:15 Break语句 发布于:2023-05-29 11:11 ## echo输出命令 发布于:2023-05-29 10:23 ## 字符串运算符 发布于:2023-05-26 15:55 ## 获取数组的所有元素 ## 获取数组的长度 发布于:2023-05-26 15:19 ## 读取数组 ## 关联数组 发布于:2023-05-26 15:10 编写shell脚本,输出0 - 500 这几个数字中,是7倍数的数字,比如7, 14, 21....,不包括0 发布于:2023-05-25 16:04 计算1-100之间的所有奇数和 发布于:2023-05-25 14:10 # shell多行注释 发布于:2023-05-25 11:59 # Shell数组 ## 定义数组 ## 读取数组 ## 获取数组的长度 发布于:2023-05-25 11:57 # Shell字符串 ## 拼接字符串 ## 提取子字符串 ## 查找子字符串 发布于:2023-05-25 11:49 删除变量简介 发布于:2023-05-25 11:31 Shell变量1 发布于:2023-05-25 11:27 脚本二温茂 发布于:2023-05-25 15:52 #从7开始循环到500,每次加7 发布于:2023-05-25 15:08 测试按行读取配置文件 发布于:2023-05-05 13:25 修改nginx监听端口 发布于:2023-04-20 16:33 比较输入数字大小 发布于:2023-04-20 15:57 [更多]
显示目录

wc命令-计算字数



wc命令

wc命令用于计算字数。

利用wc指令我们可以计算文件的Byte数、字数、或是列数,若不指定文件名称、或是所给予的文件名为"-",则wc指令会从标准输入设备读取数据。

语法

wc [-clw][--help][--version][文件...]

参数:

-c或--bytes或--chars 只显示Bytes数。
-l或--lines 只显示列数。
-w或--words 只显示字数。
--help 在线帮助。
--version 显示版本信息。

实例

在默认的情况下,wc将计算指定文件的行数、字数,以及字节数。使用的命令为:

wc testfile

先查看testfile文件的内容,可以看到:

$ cat testfile  
Linux networks are becoming more and more common, but scurity is often an overlooked  
issue. Unfortunately, in today’s environment all networks are potential hacker targets,  
fro0m tp-secret military research networks to small home LANs.  
Linux Network Securty focuses on securing Linux in a networked environment, where the  
security of the entire network needs to be considered rather than just isolated machines.  
It uses a mix of theory and practicl techniques to teach administrators how to install and  
use security applications, as well as how the applcations work and why they are necesary.

使用 wc统计,结果如下:

$ wc testfile           # testfile文件的统计信息  
3 92 598 testfile       # testfile文件的行数为3、单词数92、字节数598

其中,3 个数字分别表示testfile文件的行数、单词数,以及该文件的字节数。

如果想同时统计多个文件的信息,例如同时统计testfile、testfile_1、testfile_2,可使用如下命令:

wc testfile testfile_1 testfile_2   #统计三个文件的信息

输出结果如下:

$ wc testfile testfile_1 testfile_2  #统计三个文件的信息  
3 92 598 testfile                    #第一个文件行数为3、单词数92、字节数598  
9 18 78 testfile_1                   #第二个文件的行数为9、单词数18、字节数78  
3 6 32 testfile_2                    #第三个文件的行数为3、单词数6、字节数32  
15 116 708 总用量                    #三个文件总共的行数为15、单词数116、字节数708
由JSRUN为你提供的Shell/Bash在线运行、在线编译工具
        JSRUN提供的Shell/Bash 在线运行,Shell/Bash 在线运行工具,基于linux操作系统环境提供线上编译和线上运行,具有运行快速,运行结果与常用开发、生产环境保持一致的特点。