[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 110: Undefined array key "cached"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 111: Undefined array key "normal"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 112: Undefined array key "total"
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3391: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3393: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3394: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3395: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
Cabrillo College Linux Classes • View topic - define awk -F... please

define awk -F... please

UNIX/Linux System Administration

define awk -F... please

Postby mary talpas on Tue Dec 02, 2008 12:56 pm

I see from the lesson that we use edquota -p gimli 'awk -F': $3 > 499(print$1)' /etc/passwd' to change others users quotas to match gimli but can some explain this part of the command:
'awk -F': $3 > 499(print$1)' /etc/passwd'

thanks.
mary
mary talpas
 
Posts: 40
Joined: Tue Sep 02, 2008 8:31 pm

Re: define awk -F... please

Postby marcromansky on Tue Dec 02, 2008 1:30 pm

awk is a program within the linux operating system.
essentially here, awk reads the file /etc/password, takes every third column entry that is greater than 499 (-F: $3 > 499 in the script) and prints the 1st column

what it is doing is printing a list of usernames (1st column in /etc/passwd) with UIDs(column 3) greater than 499

[quote="mary talpas"]I see from the lesson that we use edquota -p gimli 'awk -F': $3 > 499(print$1)' /etc/passwd' to change others users quotas to match gimli but can some explain this part of the command:
'awk -F': $3 > 499(print$1)' /etc/passwd'

thanks.
mary[/quote]
marcromansky
 
Posts: 94
Joined: Tue Nov 04, 2008 7:55 pm

Re: define awk -F... please

Postby Jonathan Simms on Tue Dec 02, 2008 1:45 pm

Hi Mary,

awk, as it is generically called, is a scripting language developed by Aho, Weinberger, and Kernighan.

awk -F: '$3 > 499' '{ print $1 }' /etc/passwd

-F: is telling awk to use the colon character as a field delimiter.

'$3 > 499' This is essentially saying take the third field and see if it's greater than 499. It is using the colon character for parsing here. Looking at /etc/passwd we can see that the field we wish to use in this evaluation is the third one over, which is the UID or user id. The UID field being the third field is $3.

Accordingly $0 would print the whole line, $1 prints the username, $2 the x for passwd, $3 UID etc.

'{ print $1 }' is saying if there are UIDs greater than 499 print the first field, which is $1, which is the username.

/etc/passwd is the file we are examining.

Hope that helps.

Jonathan
Jonathan Simms
 
Posts: 119
Joined: Tue Sep 02, 2008 7:11 pm

Re: define awk -F... please

Postby Jonathan Simms on Tue Dec 02, 2008 1:47 pm

Haha Marc you got it first. I took too long writing.
Jonathan Simms
 
Posts: 119
Joined: Tue Sep 02, 2008 7:11 pm

Re: define awk -F... please

Postby mary talpas on Tue Dec 02, 2008 1:52 pm

THANK YOU :D
mary talpas
 
Posts: 40
Joined: Tue Sep 02, 2008 8:31 pm

Re: define awk -F... please

Postby marcromansky on Tue Dec 02, 2008 1:59 pm

I conveniently ditched the delimitter piece so I could get it in faster!

[quote="Jonathan Simms"]Haha Marc you got it first. I took too long writing.[/quote]
marcromansky
 
Posts: 94
Joined: Tue Nov 04, 2008 7:55 pm


Return to CIS 191B - Fall 2008

Who is online

Users browsing this forum: No registered users and 0 guests

cron