Before I added the else if/else, when i only just had the:
if (/Easy: /) .. part
The program would launch when I put awk -f oscp-notes.awk and then put input, &c.
It would then print out appropriate Easy machines; however, after I added the else if section.
It will not print either easy or medium machines now. I do not have any errors. I figured that I needed to close(file) so I could re-read. I am stuck. I would like to be able to read/close and make rest of conditional statements to include user input whether it is easy/medium/hard/insane. Is this possible?
BEGIN { <br/>
printf "Please select a chapter by entering chapter number: "
getline entry < "-"
$2 == entry
file = "TJnulls.txt"
Test if statement
if (entry == 2) {
printf "Please select difficulty (easy, medium, hard, insane): "
getline difficulty < "-"
$3 == difficulty
if (difficulty == easy) {
{print "\n"}
{print "Obtaining the list of easy machines:\n"}
while (( getline<file) > 0) {
if (/Easy: /) {
{print $2};
} else {
close("TJnulls.txt");
break;
}
}
} else if (difficulty == medium) {
{print "\n"}
{print "Obtaining the list of medium machines:\n"}
while ( ( getline<file) > 0) {
if (/Medium: /)
{print $2}
}
}
}
}