Last active
October 3, 2018 17:53
-
-
Save tarrenj/76f4221201f6e3c38950e700725f16d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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