Skip to content

Instantly share code, notes, and snippets.

@TheDcoder
Created June 30, 2022 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheDcoder/886a0bec83295b23fc9e51e3aac422a7 to your computer and use it in GitHub Desktop.
Save TheDcoder/886a0bec83295b23fc9e51e3aac422a7 to your computer and use it in GitHub Desktop.
Check if file A is a subset of file B (file B contains contents of file A)
# Example perl script to check if file A is a subset of file B (i.e. file A has any part of file B)
perl -Mautodie=open -e 'undef $/; open $f1, "<", shift; open $f2, "<", shift; exit !!(-1 == index <$f2>, <$f1>)' -- fileA fileB
# Credit: tirnanog on Libera.Chat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment