Skip to content

Instantly share code, notes, and snippets.

@tarrenj
Last active October 3, 2018 17:53
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 tarrenj/76f4221201f6e3c38950e700725f16d1 to your computer and use it in GitHub Desktop.
Save tarrenj/76f4221201f6e3c38950e700725f16d1 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# Make sure the user gave the right arguments
# Might not include this in a script to be run automatically, since returning output different from expected might break things....
if [[ $# -eq 0 ]]; then
echo
echo "Example: subtractfiles.sh allFiles.csv filesToBeSubtracted.csv"
echo
exit 1 # Non zero exit code so the build system knows something went wrong and stops...
fi
AFILE=$1
UFILE=$2
for ALINE in $(cat $AFILE); do
MATCH=0 # "Should" use a boolean for this, but it breaks things in the conditional...
for ULINE in $(cat $UFILE); do
# Determine if $ALINE is equivalent to $ULINE
if [ $ALINE = $ULINE ]; then
MATCH=1
break
fi
done
if [[ $MATCH = 0 ]]; then
echo $ALINE
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment