1 个不稳定版本
0.1.0 | 2024 年 7 月 29 日 |
---|
#1020 在 文本处理
每月下载 127 次
6KB
91 行
grep 模拟命令
概述
本项目旨在模仿 grep 命令的行为。它在文件中搜索特定字符串,并返回包含该字符串的所有行。
功能
• Case-sensitive search by default.
• Case-insensitive search available through an environment variable.
用法
命令行参数
程序需要两个命令行参数
1. Search String: The string to search for within the file.
2. File Path: The path to the file where the search will be performed.
示例
cargo run -- "搜索字符串" file.txt
不区分大小写搜索
要执行不区分大小写的搜索,请将 IGNORE_CASE 环境变量设置为 1。这将使该终端会话中的搜索不区分大小写。
示例
IGNORE_CASE=1 cargo run -- "搜索字符串" file.txt