-   Linux - Newbie (
-   -   using awk to print log in stats to a file (

demet8 10-17-2012 05:21 PM

using awk to print log in stats to a file
I am using awk to put server login's in a new file. I only need the first 10 login's along with fields 1, 5, 6 of a particular user.This is the awk command I am issuing but I am getting the entire login stats of everyone placed in the new file:

awk '(NR > 1 && NR < 11) {print $1, $5, $6}' last mark > name_date

chrism01 10-17-2012 05:49 PM

You need to specify the Field Separator as well

awk -F: '(NR > 1 && NR < 11)  {print $1, $5, $6}' last mark > name_date

demet8 10-17-2012 06:09 PM

I am now getting this error on the command line where the last mark command should be reading the last server login's for a subject named mark and then pushing that info to name_date which is a new file created. This is the error message: cmd. line:1: fatal: cannot open file `last' for reading (No such file or directory). When I use last mark @ the beginning of the command it does push out the server login's of mark but it also gives me everyone else's login's info which I don't need.

chrism01 10-17-2012 06:23 PM

Just touch the last file.

demet8 10-17-2012 09:42 PM

Thank you very much.

All times are GMT -5. The time now is 09:50 PM.