Skip to content
/ spot Public

A lightweight CLI tool in C to search and highlight text patterns in files

License

Notifications You must be signed in to change notification settings

saber-88/spot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spot

spot is a lightweight, terminal-based text search utility written in C. It allows you to search for a pattern in a file, similar to grep, with options to ignore case, highlight all matches, count occurrences, and more.


🔧 Features

  • 📌 Search for a pattern in a file
  • 🔠 Ignore case while matching
  • 🎯 Highlight all occurrences in a line
  • 🧮 Count total matches across the file
  • 🆘 Display usage/help message
  • 🌈 Color-highlighted output for matched patterns

📦 Installation

🂨 Clone the Repository

git clone https://github.com/saber-88/spot.git ~/spot
cd spot

⚙️ Run the Setup Script

./setup.sh

This script will:

  • Compile the spot.c file using make
  • Move the resulting binary to /usr/local/bin
  • Make spot globally accessible from your terminal

You may be asked to enter your password because moving files to /usr/local/bin requires root privileges.

✅ After installation, you can use the tool from anywhere by simply running:

spot <PATTERN> <FILENAME>

💻 Usage

spot [OPTIONS] <PATTERN> <FILENAME>

⚙️ Options

Flag Description
-i, --ignore-case Highlight all occurrences of pattern in a file ignoring case
-c, --count Display the total number of matches instead of matching lines
-h, --help Show help message and exit

📂 Examples

Basic match

spot hello file.txt

Ignore case

spot -i Hello file.txt

Count total occurrences

spot -c hello file.txt

Combined example

spot -i -c hello file.txt

📦 Sample Output

spot -i king book.txt
11 : There were a KING with a large jaw and a queen with a plain face...
12 : there were a KING with a large jaw and a queen with a fair face...

🤝 Contributing

Contributions, issues, and suggestions are welcome!

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-name)
  3. Make your changes
  4. Push to your branch and open a Pull Request

📜 License

This project is licensed under the MIT License – see the LICENSE file for details.


👤 Author

Developed by Karmveer

About

A lightweight CLI tool in C to search and highlight text patterns in files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published