Sponsored Content
Top Forums Shell Programming and Scripting Begin/End blocks in awk: confused Post 302882403 by newbie2010 on Monday 6th of January 2014 04:36:36 PM
Old 01-06-2014
As this script is not mine, I am curious as to why this would be included in the END part

Code:
END {
for (k in count)
    if (count[k] == 3) keyword[k] = "order this"
else print keyword[k] " " k = "order this"

I don't understand the rules for what you put in this END/BEGIN block or why. I always believed it was invoked when you were printing headers or footers, but it appears from the above that is only part of the use. Does someone have any example? I have searched but there are many and I am not sure about this rule.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BEGIN END questions

Why would you need to use this in a script? Why can't you just use print to print out what you want printed in the begining and print for what you want at the end. So this: nawk 'BEGIN {print "this is the first line"} {print $1 $2 $3} {print $5 $6} END {print "this is the last line"}' ... (2 Replies)
Discussion started by: llsmr777
2 Replies

2. Shell Programming and Scripting

begin end detection

Hi all, i am new to scripting. i need to write a code to detect begin and end of word that either begins or ends with t,th,d,dh,s,sh i have a set of words in a file containg one word per line. let the filename be aaa.txt. i have an another file bbb.txt which has two lines, just specifying the... (7 Replies)
Discussion started by: blkanth
7 Replies

3. Shell Programming and Scripting

awk BEGIN END and string matching problem

Hi, Contents of BBS-list file: foo foo foo awk ' BEGIN { print "Analysis of \"foo\"" } /foo/ { ++n } END { print "\"foo\" appears", n, "times." }' BBS-list Output: Analysis of "foo" "foo" appears 3 times. awk ' (3 Replies)
Discussion started by: cola
3 Replies

4. Shell Programming and Scripting

Use of Begin IF ,END IF END not working in the sql script

Hi I have written a script .The script runs properly if i write sql queries .But if i use PLSQL commands of BEGIN if end if , end ,then on running the script the comamds are getting printed on the prompt . Ex :temp.sql After connecting to the databse at the sql prompt i type... (1 Reply)
Discussion started by: isha_1
1 Replies

5. UNIX for Dummies Questions & Answers

Dump to another file for a begin and end Pattern

Hi All , I am newbie to linux shell scripting , below are the contents of my log file , i want the lines between a begin pattern and a end pattern for an instance , my begin Pattern is "Transaction Begins for Usr" and end pattern is "Transaction Ends for Usr" into another file Sample file... (1 Reply)
Discussion started by: SARAVANANE
1 Replies

6. Shell Programming and Scripting

strange: sed and awk print at end instead of begin of line

Hi! I have a strange behaviour from sed and awk, but I'm not sure, if I'm doing something wrong: I have a list of words, where I want to add the following string at the end of each line: \;\;\;\;0\;1 I try like this: $ cat myfile | awk '{if ( $0 != "" ) print $0"\;\;\;\;0\;1"}' Result:... (5 Replies)
Discussion started by: regisl67
5 Replies

7. Shell Programming and Scripting

Get the sum of values in between begin and end in the file

Hi All, test file Begin Script Run at Thu Mar 14 09:24:16 PDT 2013 tst_accounts: ws zip: WS_out_20130313.tar.gz dat: test_20130313.dat count: 63574 loaded: xx pre-merge: xx post-merge: xx timestamp: Thu Mar 14 09:30:42 PDT 2013 tst_accounts: ws zip: WS_out_20130313.tar.gz dat: s_20130313.dat... (6 Replies)
Discussion started by: bmk
6 Replies

8. Shell Programming and Scripting

BEGIN and END format in awk

I'm new to awk, trying to understand the basics. I'm trying to reset the counter everytime the program gets a new file to check. I figured in the BEGIN part it would work, but it doesn't. #!/bin/awk -f BEGIN {counter=0} { sum=0 for ( i=1; i<=NF;... (1 Reply)
Discussion started by: guitarist684
1 Replies

9. Shell Programming and Scripting

Search ad replace using begin and end of the file

Hello Friends , Please help to create script for compare and replace if not matches of set of lines . * Primary* Servername Server1 Location R201 Rack 4 *End Primary* *Secondary* Server Name Server1 IPAddress 10.24.30.10 Application Apache *End of Secondary* Above... (4 Replies)
Discussion started by: rnary
4 Replies

10. Shell Programming and Scripting

In ksh script what is this BEGIN and END in this function?

Can Someone please explain why BEGIN and END statement is used inside function? How does that help in scripting? function fileformatting { CleanupMask="xXxX" sed 's/^.//' < ${AllFile} > ${AllFile}.tmp echo $(wc -l ${AllFile}.tmp) `awk -v CleanupMask=${CleanupMask} ' BEGIN... (2 Replies)
Discussion started by: later_troy
2 Replies
MOKA(1)                                                      CAO-VLSI Reference Manual                                                     MOKA(1)

NAME
MOKA - Model checker ancestor ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr SYNOPSIS
moka [-VDB] fsm_filename ctl_filename DESCRIPTION
moka is a CTL model checker. Made to run on FSM or RTL descriptions, moka supports the same VHDL subset as syf or boom (for further informations about this subset see SYF(1), BOOM(1), FSM(5), VBE(5) ). Nevertheless moka imposes that each register of the behavioral description have the same clock condi- tion and that there are no tristate or multiplexed buses. In particular VHDL type MUX_BIT and WOR_BIT aren't not supported. First of all moka build the fonction transition of the FSM using a Reduced Ordered Binary Decision Diagrams representation. It then applies the initial conditions to find the first state (keyword INITIAL and/or RESET_COND in the CTL(5) file format). After it computes a symbolic simulation of the FSM in order to find all reachable states. This computation takes into account the assump- tions conditions (ASSUME keyword in the CTL(5) file format). moka finally verifies one by one each CTL formulae. (see CTL(5) for CTL file format details). CTL OPERATORS
For each CTL sub-expression moka will return the set of states that verifies the formula. For example EX(p) will return the set of reach- able states that verifies EX(p). CTL operators : EX(p) : returns all states which have almost one primary state successor that verifies p. EU(p,q) : returns all states that are the root of almost one path, such that p is true until q is always true. EG(p) : returns all states that are the root of almost one path, such that p is always true. AX(p) : returns all states which have all their primary state successor that verifies p. AU(p,q) : returns all states that are the root of only pathes from which p is true until q is always true. AG(p) : returns all states that are the root of only pathes, such that p is always true. ENVIRONMENT VARIABLES
MBK_WORK_LIB gives the path for the description and the CTL file. The default value is the current directory. MBK_CATA_LIB gives some auxiliary pathes for the descriptions and the CTL file. The default value is the current directory. OPTIONS
-V Sets verbose mode on. Each step of the model checking is displayed on the standard output. -D Sets debug mode on. Each step of the model checking is detailed on the standard output. In particular all states set are displayed for each CTL sub-expression. -B The input file is a VHDL description using the Alliance VHDL subset (see VBE(5) file format). FSM EXAMPLE
-- A multi fsm example ENTITY example is PORT ( ck : in BIT; data_in : in BIT; reset : in BIT; data_out : out BIT ); END example; ARCHITECTURE FSM OF example is TYPE A_ETAT_TYPE IS (A_E0, A_E1); SIGNAL A_NS, A_CS : A_ETAT_TYPE; TYPE B_ETAT_TYPE IS (B_E0, B_E1); SIGNAL B_NS, B_CS : B_ETAT_TYPE; --PRAGMA CURRENT_STATE A_CS FSM_A --PRAGMA NEXT_STATE A_NS FSM_A --PRAGMA CLOCK ck FSM_A --PRAGMA FIRST_STATE A_E0 FSM_A --PRAGMA CURRENT_STATE B_CS FSM_B --PRAGMA NEXT_STATE B_NS FSM_B --PRAGMA CLOCK ck FSM_B --PRAGMA FIRST_STATE B_E0 FSM_B SIGNAL ACK, REQ, DATA_INT : BIT; BEGIN A_1 : PROCESS ( A_CS, ACK ) BEGIN IF ( reset = '1' ) THEN A_NS <= A_E0; DATA_OUT <= '0'; REQ <= '0'; ELSE CASE A_CS is WHEN A_E0 => IF ( ACK ='1') THEN A_NS <= A_E1; ELSE A_NS <= A_E0; END IF; DATA_OUT <= '0'; REQ <= '1'; WHEN A_E1 => IF ( ACK ='1') THEN A_NS <= A_E1; ELSE A_NS <= A_E0; END IF; DATA_OUT <= DATA_INT; REQ <= '0'; END CASE; END IF; END PROCESS A_1; A_2 : PROCESS( ck ) BEGIN IF ( ck = '1' AND NOT ck'STABLE ) THEN A_CS <= A_NS; END IF; END PROCESS A_2; ------- B_1 : PROCESS ( B_CS, ACK ) BEGIN IF ( reset = '1' ) THEN B_NS <= B_E0; DATA_INT <= '0'; ACK <= '0'; ELSE CASE B_CS is WHEN B_E0 => IF ( REQ ='1') THEN B_NS <= B_E1; ELSE B_NS <= B_E0; END IF; DATA_INT <= '0'; ACK <= '0'; WHEN B_E1 => IF ( REQ ='1') THEN B_NS <= B_E1; ELSE B_NS <= B_E0; END IF; DATA_INT <= DATA_IN; ACK <= '1'; END CASE; END IF; END PROCESS B_1; B_2 : PROCESS( ck ) BEGIN IF ( ck = '1' AND NOT ck'STABLE ) THEN B_CS <= B_NS; END IF; END PROCESS B_2; END FSM; CTL EXAMPLE
-- A CTL file example TYPE A_ETAT_TYPE IS (A_E0, A_E1); TYPE B_ETAT_TYPE IS (B_E0, B_E1); VARIABLE A_NS, A_CS : A_ETAT_TYPE; VARIABLE B_NS, B_CS : B_ETAT_TYPE; VARIABLE ck : BIT; VARIABLE data_in : BIT; VARIABLE data_out : BIT; VARIABLE reset : BIT; VARIABLE ack : BIT; VARIABLE req : BIT; RESET_COND init1 := (reset='1'); ASSUME ass1 := (reset='0'); begin prop1 : EX( ack='1' ); prop2 : AG( req -> AF( ack ) ); prop4 : AU( req='1', ack='1'); end; MOKA EXAMPLE
moka -V example example SEE ALSO
syf (1), fsp (1), fsm (5), ctl (5), vbe(5). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 August 5, 2002 MOKA(1)
All times are GMT -4. The time now is 01:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy