Sponsored Content
Top Forums Shell Programming and Scripting Explaination on Behavior of awk command Post 302840193 by chandana hs on Monday 5th of August 2013 01:47:52 AM
Old 08-05-2013
Hello,
Thanks, the solution provided worked...

Sorry for the missing input file.

Code:
 $ grep -e "Cyclomatic complexity" -e ";add;" inspect_64d_369980 | head -5
  Thread.cpp;176;25;Error;;3;NPD.FUNC.MUST;Error;add;-73966069;Pointer 'handle.operator->()' returned from call to function 'operator->' at line 176 may be NULL and will be dereferenced at line 176.;;Existing;;Analyze;2254;https://insight-review.html#goto:project= 64_d,pid=2254
  Bond.cxx;268;8;Error;;3;MLK.MIGHT;Error;add;-1408122275;Possible memory leak. Dynamic memory stored in 'bond' allocated through function 'new' at line 249 can be lost at line 268;;Existing;;Analyze;3998;https://insight-review.html#goto:project=64_d,pid=3998
  DescHolder.hpp;168;41;Error;;3;NPD.FUNC.MUST;Error;add;-116936433;Pointer 'conn.operator->()' returned from call to function 'operator->' at line 168 may be NULL and will be dereferenced at line 168.;;Existing;;Analyze;13987;https://insight-review.html#goto:project=64_d,pid=13987
  Command.java;62;22;Style;;8;JD.VNU;Warning;add;-934426595;Variable 'result' was never read after being assigned.;;Existing;;Analyze;16949;https://insight-review.html#goto:project=64_d,pid=16949
  FilterCommand.java;63;28;Style;;8;JD.VNU;Warning;add;104541;Variable 'irf' was never read after being assigned.;;Existing;;Analyze;16950;https://insight-review.html#goto:project=64_d,pid=16950




Output (worked
after changing from " to ')
Code:
 $ awk -F">20" "/Cyclomatic complexity/ && /;add;/{print \$1}" inspect_64d_369980 | awk '{print $NF}' | sort | tail -1
  65
  $ awk -F">20" '/Cyclomatic complexity/ && /;add;/{print $1}' inspect_64d_369980 | awk '{print $NF}' | sort | tail -1
  65
  $ var=`awk -F">20" "/Cyclomatic complexity/ && /;add;/{print \$1}" inspect_64d_369980 | awk '{print $NF}' | sort | tail -1`;echo $var
  65>20;;Existing;;Analyze;21190;https://insight-review.html#goto:project=64_d,pid=21190
  $var=`awk -F">20" '/Cyclomatic complexity/ && /;add;/{print $1}' inspect_64d_369980 | awk '{print $NF}' | sort | tail -1`;echo $var 
  65
  $ var=$(awk -F">20" '/Cyclomatic complexity/ && /;add;/{print $1}' inspect_64d_369980 | awk '{print $NF}' | sort | tail -1);echo $var
65

Thanks for the replies and solutionSmilie

Last edited by Don Cragun; 08-05-2013 at 03:19 AM.. Reason: CODE tags
 

9 More Discussions You Might Find Interesting

1. Linux

I would like to know the explaination.

Hi, I'm new to LINUX Scripting, I would like to know the full explaination of the below scripts. thank you. 1st script #! /bin/sh . /opt/home/hssadmin/cindy/formatxml.env `testrecord.scp` `testEXGU.scp` 2nd Script #! /bin/sh . /opt/home/hssadmin/cindy/formatxml.env cd... (1 Reply)
Discussion started by: AudreyEliza
1 Replies

2. Shell Programming and Scripting

Looking for awk code explaination

{ # print NF,NR,$0; if ( ($(NF-1) != 0) && ($NF != 0) ) {if ($(NF-1) > $NF) {percent=$(NF-1)/$NF-1;} else {percent=$NF/$(NF-1)-1;} } printf "%8.4f\%\n",percent*100; if (percent > 0.05||percent < -0.05 ){exit 1;} }' Use code tags please, ty. Also try to use a more... (1 Reply)
Discussion started by: bosmat shani
1 Replies

3. Shell Programming and Scripting

awk print behavior weird

Hi Experts I am facing a weird issue while using print statement in awk. I have a text file with 3 fields shown below: # cat f1 234,abc,1000 235,efg,2000 236,jih,3000 # When I print the third column alone, I dont face any issue as shown below: # awk '{print $3 }' FS=, f1 1000 2000... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

4. Red Hat

BASH command not found strang behavior

Hi all I am relatively new to linux (specifically red hat). I have installed Fedora 13 on my machine and started playing with the terminal when i found a very strange behavior when typing a command that is not found: the terminal does not prompt me back. In other words, i am logged as root (or... (4 Replies)
Discussion started by: abohmeed
4 Replies

5. UNIX for Advanced & Expert Users

Behavior of Find command

Centos 5.8 Lets say I have 2 nfs shares mounted to /folder1 and /folder2. If I do a find / -name *something* Will it also search the 2 nfs shares ? If so is there a way to avoid this? Thanks (2 Replies)
Discussion started by: whegra
2 Replies

6. Shell Programming and Scripting

Explaination on export command

Hello Team, Could you pls explain how export command works in below code: for i in ${!SDV_*}; do export $i done As per my understanding, if SDV_1=test1;SDV_2=test2;test1=var1;test2=var2then in for loop below export will get executed. export var1;export var2But, Will this... (3 Replies)
Discussion started by: chandana.hs
3 Replies

7. Shell Programming and Scripting

Strange behavior of find and rm command

Hi I run the below command to find and delete *.xml files 90 or more days old. find . -type f -name '*.xml' -mtime +90 -exec rm {} \; find: stat() error ./Hello/2014_EMPTY.xml: No such file or directory ./Hello/2014_EMPTY_8011.xml: No such file or directory ..... .... If the file... (10 Replies)
Discussion started by: mohtashims
10 Replies

8. UNIX for Beginners Questions & Answers

awk Behavior

Linux Release Uname details Data file Ive been at the command line for some time. Back as far as SCO and Interactive Unix. I have always used this construct without issues. I want to isolate the ip / field 1. As you can see .. the first line is "skipped". This works as... (6 Replies)
Discussion started by: sumguy
6 Replies

9. UNIX for Advanced & Expert Users

Strange behavior from kill command

I am getting some strange behaviour from the kill command. When I run the which command it says it points to /usr/bin/kill. When I look at my PATH I have /usr/bin in it. So why does running kill or /usr/bin/kill produce different outputs? ghost ~ $ which kill /usr/bin/kill ghost ~ $ kill... (5 Replies)
Discussion started by: cokedude
5 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 02:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy