Let's look at Magic Banana's awk command
You did not copy the second argument, -, which is essential: it is the
standard input, as always with GNU commands. Here: the output of sort -u
IPv4.May2020.37.nMapoG.txt.
so ARGV[1] has to be www.newsgeni.us and ARGV[2] ought to be 10.
No. ARGV contains the arguments given to AWK. Here: ARGV[1] is PTRList.txt
and ARGV[2] is -, the standard input. Excerpt from 'man awk':
ARGV Array of command line arguments. The array is indexed from 0 to
ARGC - 1.
./MB.suggestion.bin: line 1: $: command not found
awk: cmd. line:1: (FILENAME=- FNR=2) fatal: can't redirect to
`out/2,lo0-100.NYCMNY-VFTTP-421.verizon-gni.net' (No such file or directory)
You apparently copied a command line, including the prompt ($, which is not a
command, as the error says), not the script in
https://trisquel.info/forum/find-instances-each-list-strings-and-print-each-set-separate-file#comment-150649
Also, a shell script is not a binary, contrary to what the extension you
chose suggests. The usual extension is "sh", but there is no need to give an
extension.
If you had properly copied the script, you would have got the help message
(because the test [ -z "$3" ] passes: the third argument is empty). It would
have informed you that, after the two files, you must give the output
directory. In the script, mkdir -p "$3" creates that directory (and even its
parent directories) if it does not exists.
. could be a default value for that third argument, complementing the script
in this way:
#!/bin/sh
if [ -z "$2" ]
then
printf "Usage: $0 PRT_list IPv4_addresses [output_dir]
Both files must have two fields. The first field must be the PTR and must be
unique in PTR_list.
"
exit
fi
out=.
if [ -n "$3" ]
then
mkdir -p "$3"
out="$3"
fi
sort -u "$2" | awk -v out="$out/" 'FILENAME == ARGV[1] { a[$1] = $2 }
FILENAME == ARGV[2] && $1 in a { print $2 >> out a[$1] "," $1 }' "$1" -
Just in case, I'll sort PTRList.txt before running ./MB.suggestion.bin
It is useless.
Now lo0-100.NYCMNY-VFTTP-421.verizon-gni.net in the error response is the
same as the first argument of MB.suggestion.sort.bin. That's progress.
No it is not. You should try to understand what you are executing instead of
doing random things such as sorting "just in case". Read the help message I
wrote: the first argument is called "PTR_list". Not "PTR". It is a file.
The rest of the message confirms it: "Both files...". Example of a call of
the script (I named it "join-and-group-by-ptr": give meaningful names!),
which here writes the files in the directory "out":
$ ./join-and-group-by-ptr PTRList.txt IPv4.May2020.37.nMapoG.txt out