



	Lab 10 Solutions

	1.	/ford/    { fordtot += $5   }
                /chevy/   { chevytot += $5  }
                /plym/    { plymtot += $5   }
                /volvo/   { volvotot += $5  }
                /fiat/    { fiattot += $5   }
                /honda/   { hondatot += $5  }

                END {  printf("Ford:    %7d\n", fordtot)
                       printf("Chevy:   %7d\n", chevytot)
                       printf("Plym:    %7d\n", plymtot)
                       printf("Volvo:   %7d\n", volvotot)
                       printf("Fiat:    %7d\n", fiattot)
                       printf("Honda:   %7d\n", hondatot)
                    }

	2.      See next page.

        3.      awk '{temp=$2; $2=$1; $1=temp","; print }' Misc/list


        4. 	(Script follows)

      # This is a shell script that uses awk to perform the following exercise: 
      # In the line for your login name in the password file, do each of these:
      #   a. Change the name field to NAME
      #   b. Change the password field to PASSWORD
      #   c. Change the id field to ID
      #   d. Change the command field to COMMAND
      #   e. Delete the id field.  Leave successive colons.

      grep $LOGNAME /etc/passwd | awk -F':' '{ $1="NAME"; print }' OFS=":"

      grep $LOGNAME /etc/passwd | awk -F':' '{$2="PASSWORD"; print }' OFS=":"

      grep $LOGNAME /etc/passwd | awk -F':' '{$3="ID"; print }' OFS=":"

      grep $LOGNAME /etc/passwd | awk -F':' '{$NF="COMMAND"; print }' OFS=":"

      grep $LOGNAME /etc/passwd | awk -F':' '{$3=""; print}' OFS=":"
