Hide output of a certain file on print

Im trying to print /etc/passwd with a variable connecting to /etc group/
But when im trying to print the output, /etc/group is printing also. Can i ask for help on what command to use
so it will ignore /etc/group and only print /etc/passwd.

here's the sample script. pages number and the /10 entry line pages should be used also.

 awk -F":" -v A=$(wc -l < /etc/passwd) '
    BEGIN   {
            NUM_PAGES=A/10+1
            print "--------------------------------------------------"
            printf "%-20s %-20s %-3s\n","USERNAME","GUID","DIRECTORY"
            print "--------------------------------------------------"
            }

   !(NR%10) {
             PAGE++
             printf "--- Page %d of %d ---",PAGE,NUM_PAGES
             getline rc < "-"; system("tput cuu1")
            }

   (NR==FNR){
            B[$3]=$1
            next } $4 in B { $4=B[$4]
            }


            { printf "%-20s %-20s %-3s\n", $1, $4, $7 }

' /etc/group /etc/passwd

Just reverse the order of the statements, i.e. have the file1 processing (NR==FNR) before the page processing !(NR%10) . And, use FNR for the latter.

Be aware that careful indenting (as shown by Scrutinizer in your other thread) helps others (and you!) to easily read and understand your code.

1 Like

Thank you Sir!
Will have to study a lot more.
Have a magnificent day.