Skip to content

Instantly share code, notes, and snippets.

@cpburnz
Last active August 29, 2015 14:05
Show Gist options
  • Save cpburnz/d54afa685fb25b99c8e1 to your computer and use it in GitHub Desktop.
Save cpburnz/d54afa685fb25b99c8e1 to your computer and use it in GitHub Desktop.
From a bash shell, grep file names received from STDIN. The file names may contain spaces.
#!/bin/bash
#
# From a bash shell, grep file names received from STDIN. The file names may
# contain spaces.
#
# Author: Caleb P. Burns
# License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# Version: 1.0.0
# 1. Find the files to grep.
# 2. Sort them.
# 3. Grep each file's contents.
find ... -print0 | sort | xargs -0 grep --color=always ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment