Sponsored Content
Top Forums Shell Programming and Scripting AWK deifnition and some small code explanation Post 302196332 by amatuer_lee_3 on Saturday 17th of May 2008 09:57:04 PM
Old 05-17-2008
AWK deifnition and some small code explanation

Could someone give me a quick simple explanation for the AWK command.

And also help me to explain the code i have made. I have made some general comments about it myself. I was wondering if people could help me with the rest:

Code:
awk -F'[: ]' 'END {
fmt = "%-20s\t%s\t%s\n"                            # Formats the table output
printf fmt, "Page:", "Hits:", "Unique Hits:"       # Defines Column Headers
for (p in h)
  printf fmt, p, h[p], u[p]
}
!_[$1,$2]++ { u[$1]++ } 		          # u[x] counts the number of occurrences of x in field column 1.
{ h[$1]++ }' HITS |				     # h[x] counts the number of occurrences of x in field column 1.
( IFS='' read header; echo "$header"; sort -k2rn )  # discard any duplicates where same combination of column 1 and 2 has been seen before

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK explanation

Hi, Could anyone please explain why we have arr=1 - what does this statement do? awk -F\; 'FNR==NR{arr=1;next};$3 in arr' core.txt gmrd.txt Any help appreciated (2 Replies)
Discussion started by: penfold
2 Replies

2. Shell Programming and Scripting

Need explanation for the syntax(code)

Hi I am new to shell script programming... want to know the process of the following: if then echo "$0: missing argument for option(s) :$MISSINGOPTARG" echo "usage" $USAGE" exit 1 fi (1 Reply)
Discussion started by: chandhar
1 Replies

3. Shell Programming and Scripting

nawk code explanation

Hi I have a line/command which greps certain pattern () from the file and 22 lines AFTER that: nawk '/\/{c=22}c&&c--' input_file Can somebody explain the coding in this command (what " c&&c-- " does)? and how to modify this command to output 22 lines BEFORE this pattern () Thanks a lot ... (3 Replies)
Discussion started by: aoussenko
3 Replies

4. Homework & Coursework Questions

Please help with the following fork code..with complete explanation

I have the following piece of codes. Please explain it to me in great detail how are these codes working. 1. #include <stdio.h> int main(){ int x; x=0; while (x<2 && fork()){ if (!fork()) execlp("echo","x++","x",0); x++; system("echo x+x"); } } 2. #include <stdio.h> int i;... (1 Reply)
Discussion started by: prakashabii
1 Replies

5. Shell Programming and Scripting

code explanation

Can you please explain the following code plz? my_cd=' ' while getopts :e: OPTION; do case "$OPTION" in e) my_cd ="$OPTARG";; esac done if ; then echo " >>> ERROR - I am wrong" echo " >>> ERROR - Hello" exit 99 fi What I don't understand is what is OPTION or... (3 Replies)
Discussion started by: RubinPat
3 Replies

6. Shell Programming and Scripting

awk explanation

Hello, I have recently come across this awk program. Can some one shed some light on what is taking place. awk '{!a++}END{for(i in a) if ( a >10 ) print a,i }' $FILE Best Regards, jaysunn (1 Reply)
Discussion started by: jaysunn
1 Replies

7. Shell Programming and Scripting

Help with explanation of awk parameters

Hello, Would someone be able to tell me exactly how this command works please? awk '!x++' As usual any help much appreciated (8 Replies)
Discussion started by: Grueben
8 Replies

8. UNIX for Dummies Questions & Answers

Explanation of NAWK Code

Hi all, I need your help in understanding the meaning and syntax of the below nawk line. Here is an extract of a script which I use daily and works well. The script extracts the hostnames and messages within a syslog file. I would also like to extract the message time in the 3rd column by... (2 Replies)
Discussion started by: wthomas
2 Replies

9. UNIX for Dummies Questions & Answers

Code explanation?

I need someone to tell me how exactly works the following code αfter /etc/passwd :eek:: cat /etc/passwd|grep "^:"|sed '1,$s/^\(*\):*:\(*\):.*$/ \1 \2 /'|sort -nrk3 -t:I want a good explanation to understand the code please (4 Replies)
Discussion started by: kotsos13
4 Replies

10. Shell Programming and Scripting

ksh code explanation

Hi. Can somebody please explain the following lines of KSH code for me? The code checks all sub directories in a specific location which are numbered (E.g. test_01, test_02 ... etc.), then finds the one with highest number and extracts that number from the dir name into the variable num. I'd just... (9 Replies)
Discussion started by: user052009
9 Replies
DATEFMT_GET_DATETYPE(3) 						 1						   DATEFMT_GET_DATETYPE(3)

IntlDateFormatter::getDateType - Get the datetype used for the IntlDateFormatter

	Object oriented style

SYNOPSIS
public int IntlDateFormatter::getDateType (void ) DESCRIPTION
Procedural style int datefmt_get_datetype (IntlDateFormatter $fmt) Returns date type used by the formatter. PARAMETERS
o $fmt - The formatter resource. RETURN VALUES
The current date type value of the formatter. EXAMPLES
Example #1 datefmt_get_datetype(3) example <?php $fmt = datefmt_create( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); echo 'datetype of the formatter is : ' . datefmt_get_datetype($fmt); echo 'First Formatted output with datetype is ' . datefmt_format($fmt, 0); $fmt = datefmt_create( 'en_US', IntlDateFormatter::SHORT, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); echo 'Now datetype of the formatter is : ' . datefmt_get_datetype($fmt); echo 'Second Formatted output with datetype is ' . datefmt_format($fmt, 0); ?> Example #2 OO example <?php $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); echo 'datetype of the formatter is : ' . $fmt->getDateType(); echo 'First Formatted output is ' . $fmt->format(0); $fmt = new IntlDateFormatter( 'en_US', IntlDateFormatter::SHORT, IntlDateFormatter::FULL, 'America/Los_Angeles', IntlDateFormatter::GREGORIAN ); echo 'Now datetype of the formatter is : ' . $fmt->getDateType(); echo 'Second Formatted output is ' . $fmt->format(0); ?> The above example will output: datetype of the formatter is : 0 First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT Now datetype of the formatter is : 2 Second Formatted output is 12/31/69 4:00:00 PM PT SEE ALSO
datefmt_get_timetype(3), datefmt_create(3). PHP Documentation Group DATEFMT_GET_DATETYPE(3)
All times are GMT -4. The time now is 06:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy