8000 A little help to find any occurrence from a line on another file · thiagosanches/my-recipes@e8e56c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
A little help to find any occurrence from a line on another file
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagosanches committed Feb 23, 2024
1 parent 43f9c3e commit e8e56c7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions linux/bin/match.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# This script searches for a specific line stored in FILE1 and attempts to find a matching occurrence in FILE2.
# Usage:
# ./match.sh file1.txt file2.txt

FILE1="$1"
FILE2="$2"

NO_COLOR="\033[0m"
RED_COLOR="\033[0;31m"
PURPLE_COLOR="\033[0;35m"

for t in $(cat "$FILE1")
do
grep --quiet "${t}" "${FILE2}"
if [[ $? -eq 0 ]]
then
echo -e "${t}\t${PURPLE_COLOR}MATCHES${NO_COLOR} in ${FILE2}"
else
echo -e "${t}\t${RED_COLOR}NO MATCH${NO_COLOR} in ${FILE2}"
fi
done

0 comments on commit e8e56c7

Please sign in to comment.
0