Skip to content

Instantly share code, notes, and snippets.

@sephraim
Last active September 24, 2019 19:40
Show Gist options
  • Select an option

  • Save sephraim/dd1ffcbfa37c979b66052f25922e3cc7 to your computer and use it in GitHub Desktop.

Select an option

Save sephraim/dd1ffcbfa37c979b66052f25922e3cc7 to your computer and use it in GitHub Desktop.
Find files that contain one specific line but not another
# Find files that:
# 1.) are .rb files
# 2.) contain 'last_name'
# 3.) do NOT contain 'name_suffix'
# USING AG
ag -LG '.*\.rb' 'name_suffix' . | xargs ag 'last_name'
# USING GREP
find . -name "*.rb" -print | xargs grep -l 'last_name' | xargs grep -L 'name_suffix'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment