Percol - Interactive Shell Filtering Tool

Learn how to use Percol, an interactive shell filtering tool, to enhance your command-line workflow. Discover installation and usage examples for interactive pgrep and pkill.

Percol

What is Percol?

Percol is a powerful command-line utility that enhances the traditional UNIX pipe concept by adding interactive filtering capabilities. It allows you to filter and select data from standard input in real-time, making complex command-line operations more intuitive and efficient. By providing an interactive interface, Percol helps developers refine their command-line workflows, especially when dealing with large datasets or complex process management.

Installing Percol

Installing Percol is straightforward. You can typically install it using pip, the Python package installer. Ensure you have Python and pip installed on your system.

# To install percol
sudo pip install percol

Interactive Filtering Examples

Percol shines when used in conjunction with other command-line tools. Here are a couple of common use cases:

Interactive pgrep Version

This example demonstrates how to use Percol to interactively filter the output of ps aux (which lists running processes) and then extract only the process IDs (PIDs). This is useful for finding specific processes before acting upon them.

ps aux | percol | awk '{ print $2 }'

Interactive pkill Version

Building on the previous example, this command allows you to interactively select processes from the ps aux output and then terminate them using xargs kill. Percol's interactive selection makes it safer and easier to kill the correct processes.

ps aux | percol | awk '{ print $2 }' | xargs kill

Benefits of Using Percol

  • Interactivity: Provides a real-time, interactive way to filter command-line output.
  • Efficiency: Speeds up complex command-line tasks by allowing quick selection.
  • Safety: Reduces errors when performing actions like killing processes by enabling careful selection.
  • Flexibility: Works seamlessly with existing UNIX tools and pipes.

External Resources