360 Secure SkillHub
360 安全技能中心

Wc Lines Tool

wc-lines-tool 是一个命令行行数统计工具,可处理字符串、文件或标准输入,输出总行数、空行、非空行与代码行数;支持 --min/--max 阈值退出码检查及 JSON 结构化输出,适用于代码统计、日志大小与文档分析。

dinghaibin
dinghaibin
热度 27.62
最近更新 2026-05-11 17:48:15
分类:效率依赖:代码执行 / 读写文件应用场景:数据处理 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add wc-lines-tool
Metadata
name
wc-lines-tool
description
Count lines, blank lines, code lines, and comment lines in text files. Useful for code statistics, log file sizing, and document analysis.

WC Lines Tool — Line Counting Utility

Count lines in text input with smart detection of blank lines, code lines, comment lines, and non-empty content. Ideal for codebases, log analysis, and document statistics.

Quick Start

# Count lines in a string
wc-lines-tool "line1\nline2\nline3"

# Count lines from stdin
cat README.md | wc-lines-tool

# Count lines in a file
wc-lines-tool --file log.txt

Usage

wc-lines-tool [TEXT] [OPTIONS]
wc-lines-tool --file FILE [OPTIONS]

Options:
  --file FILE       Read from file instead of argument
  --non-blank       Count only non-empty lines
  --blank           Count only blank/empty lines
  --code            Count lines likely containing code (non-comment, non-blank)
  --max N           Report if line count exceeds N (exit 1 if over)
  --min N           Report if line count is below N (exit 1 if under)
  --json            Output as structured JSON

Examples

# Total line count
wc-lines-tool --file server.log

# Non-blank lines only
wc-lines-tool --file app.py --non-blank

# Blank line count
wc-lines-tool --file main.go --blank

# Check log file size threshold (alert if > 10000 lines)
wc-lines-tool --file errors.log --max 10000

# Machine-readable output
wc-lines-tool --file data.csv --json

Features

  • Line counting — total, blank, non-blank, code
  • File, stdin, and argument input — flexible sources
  • Threshold alerts — --min/--max with exit codes for CI/CD
  • JSON output — pipeline-friendly
  • Fast — handles large files efficiently
  • UTF-8 safe — handles arbitrary encodings