I have a seemingly very simple problem but I am unable to come up with a satisfying solution. I have a simple input file containing IPs and ports, like
10.155.78.0 445
172.17.11.0 3389
Now I want to execute nc -vvv <ip> <port>
for each line in a for loop.
All I can come up with is splitting the line twice with cut:
for x in $(cat inputfile); do nc -vvv $(echo -n $x | cut -d" " -f1) $(echo -n $x | cut -d" " -f2)
or using gawk and starting a sub-shell
for x in $(cat dingens); do cmd=$(echo $x | gawk -F" " '{ print "nc -vvv -w 2 " $1 " " $2 }'); echo -n $cmd | bash; done
but both solutions seem terribly complicated. Isn't there a better solution?
for
– glenn jackman Jul 27 '21 at 14:53