combined-head-linecount-check
Screenshots
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "combined-head-linecount-check" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ba570f6c0aaf0746b877afc7dce6df03442e1ef4e474727c55930b4530bd6692. Verify the upstream source and version against https://github.com/HKUDS/OpenSpace before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Validate a file's first N lines and total line count in a single shell invocation using head and wc -l, separating outputs with echo delimiters to minimize read operations and shell iterations.
Introduction source: third_party · HKUDS · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Verify a file's first N lines and total line count in one shell call using head and wc -l with an echo separator, minimizing read operations and shell iterations.
- Testing
- Not tested
Browse files
Frontmatter
name: combined-head-linecount-check
description: Verify a file's first N lines and total line count in one shell call using head and wc -l with an echo separator, minimizing read operations and shell iterations.Combined Head + Line Count Check
When you need to both inspect the top of a file and confirm its total line count, collapse the two checks into a single run_shell call instead of issuing two separate commands.
Why
- Each shell call is a round-trip. Two separate calls (
headthenwc -l) cost two iterations. - A combined call costs one iteration and returns both pieces of information atomically.
- When checking multiple files at once, each file still only needs one call (or all files can be parallelized in a single compound command).
Pattern
head -N <file> && echo "---" && wc -l <file>
The echo "---" separator makes the output easy to parse visually: everything above the dashes is content, everything below is the line count.
Examples
Single file — inspect first 10 lines and total count
head -10 src/main.ts && echo "---" && wc -l src/main.ts
Sample output:
import { createApp } from 'vue'
import App from './App.vue'
...
---
142 src/main.ts
Multiple files — fully parallelized
When you need to check several files simultaneously, run them all in one shell call using && chains or newline-separated subshells:
(head -10 src/main.ts && echo "---" && wc -l src/main.ts) && echo "===" && \
(head -10 vite.config.ts && echo "---" && wc -l vite.config.ts) && echo "===" && \
(head -5 package.json && echo "---" && wc -l package.json)
Or, if order independence is acceptable, run them in parallel background jobs and wait:
{
head -10 src/main.ts && echo "---" && wc -l src/main.ts
} &
{
head -10 vite.config.ts && echo "---" && wc -l vite.config.ts
} &
wait
When to Apply
| Situation | Recommendation |
|---|---|
| Verifying a generated/modified file was written correctly | ✅ Use combined call |
| Checking multiple output files after a build step | ✅ Parallelize all in one shell call |
| Only need line count (no content preview required) | Use plain wc -l |
| Only need content (no line count required) | Use plain head -N |
| File is extremely large and you want a middle section | Use sed -n or awk instead |
Integration with Parallel Reads
This pattern compounds well with parallel file reads. In a single iteration you can:
- Read file contents with
catorheadfor multiple files. - Simultaneously verify line counts with
wc -l. - Check for specific patterns with
grep -c.
Example of a 5-file parallel verification in one shell call:
echo "=== main.ts ===" && head -10 src/main.ts && echo "lines:" && wc -l < src/main.ts && \
echo "=== config ===" && head -5 vite.config.ts && echo "lines:" && wc -l < vite.config.ts && \
echo "=== package ===" && head -5 package.json && echo "lines:" && wc -l < package.json && \
echo "=== index ===" && head -8 index.html && echo "lines:" && wc -l < index.html && \
echo "=== readme ===" && head -5 README.md && echo "lines:" && wc -l < README.md
Tip: Using
wc -l < file(with input redirect) prints only the number, without the filename — cleaner output when the filename is already shown by theecholabel above it.
Key Takeaway
Never use two shell calls where one will do. Combining
head -Nandwc -lin a single command is the minimal-overhead way to answer both "what does this file contain?" and "is it the right size?" simultaneously.
Current listing version
0.0.1
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供了一种高效合并 head 和 wc -l 调用的实用技巧,减少 shell 迭代次数
- 适用于开发、运维等需要快速验证文件内容和行数的场景
Areas to improve
-
触发词缺失 Reported severity: Minor
description 内容完整,但未在 frontmatter 中定义明确的触发关键词或命令别名
Recommendation: 建议在 frontmatter 中添加 keywords 字段,包含如 head、wc、line count、file check 等触发词,提升匹配精准度
Highlights
- description 清晰描述了核心功能和适用场景
Highlights
- 文档结构完整,包含 Why、Pattern、Examples、When to Apply 等逻辑清晰的章节
- 提供了丰富的单文件和批量文件使用示例,便于用户理解和应用
Areas to improve
-
异常处理未覆盖 Reported severity: Minor
未处理文件不存在、权限不足等常见 shell 执行异常情况
Recommendation: 建议在文档中添加错误处理说明,例如使用 test -f 检查文件存在性,或在命令链中加入错误退出码处理
Highlights
- shell 命令语法正确,参数使用合理,输出格式清晰易解析
- 提供了并行化处理多个文件的优化方案
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.