Created
December 11, 2019 14:23
-
-
Save N1v0k/7d1f5ccd7dc1fdddabb52e48857a933c to your computer and use it in GitHub Desktop.
Reads a file line-by-line and applies regex with two groups and checks if left string is present in right string
This file contains hidden or 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
#!/bin/bash | |
# Reads a file line-by-line and applies regex with two groups and checks if left string is present in right string | |
regex="([0-9]{10})#PHVN(.*)" | |
while IFS="" read -r p || [ -n "$p" ] | |
do | |
line=$(printf '%s\n' "$p") | |
if [[ $line =~ $regex ]] | |
then | |
needle="${BASH_REMATCH[1]}" | |
hay="${BASH_REMATCH[2]}" | |
if [[ ! "$hay" =~ "$needle" ]]; then | |
echo "$line" | |
fi | |
fi | |
done < "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment