I found myself having to learn a bit of awk, and it's really cool, but I have a small problem I am facing.
I have a script that has an output that is designed to be piped. Let's call it matrix.
I also have a local text file blacklist.txt over which I have complete control and can format any way I want. It only contains 1 column (or one set of values)
I want to run the script, pipe it, compare one of the resulting column values with each line (or comma separated) value in the text file, and if it's a match executing something else.
I want to run the following (with some pseudo code):
matrix username | // this returns an output and is piped
// I then want to awk in a blacklist of usernames from my file,
//not sure if I should use getline
awk '{print $1}' blacklist.txt
// And now, I would like to compare the two, and execute another command
if($4 from matrix == $1 from blacklist.txt) {
matrix doSomething
}
else {
print "Not valid"
}
Any pointers would be greatly appreciated. Thank you.
matrix doSomethingfor each line that matches?| while read -r one to three four others; do something_with_four?