AWK command giving wrong input


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers AWK command giving wrong input
# 1  
Old 04-01-2009
Question AWK command giving wrong input

Hi all,

I have a problem with qwk command.

i have to check process status and for that i am using command
prstat -mvL 1 1
and it gives me the entire output
but when i use this command with awk like this:
prstat -mvL 1 1 | awk -F" " '{print $1,$15}'
to get first and 15th arguments.

but when i give this command i dont get the entire output which i get when i give just prstat -mvL 1 1
Any ideas why this is happening??

Thanks in advance
U
# 2  
Old 04-01-2009
Post the output of your prstat command and the desired output within code tags (select the text with your mouse and press the # above the edit box).

Regards
# 3  
Old 04-01-2009
Hi Franklin,
When i use just this command:

prstat -mvL 1 1
i get
Code:
 
"PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID
  8606 oasis     18 4.1 0.0 0.0 0.0 0.0  78 0.0  26 186  9K   0 java/140
  8606 oasis     17 4.5 0.0 0.0 0.0 0.0  79 0.0  42 125  9K   0 java/142
  1275 oasis    2.1  19 0.0 0.0 0.0 0.0  80 0.0  62  71  2K   0 prstat/1
  8606 oasis     17 4.2 0.0 0.0 0.0 0.0  79 0.0  30 209  6K   0 java/143
  8606 oasis    9.9 0.0 0.0 0.0 0.0 0.0  90 0.0   6  66  33   0 java/133
  8606 oasis    4.9 0.7 0.0 0.0 0.0 0.0  94 0.0   9  50  2K   0 java/134
  3086 oasis    5.0 0.1 0.0 0.0 0.0 0.0  59 0.0  23  22  56   0 java/4
  3085 oasis    3.2 0.1 0.0 0.0 0.0 0.0  60 0.0  20  15  49   0 java/4
 24127 oasis    2.5 0.2 0.0 0.0 0.0 1.0  65 0.0  22  26 124   0 java/8
 24127 oasis    2.5 0.2 0.0 0.0 0.0 1.2  65 0.0  22  27 125   0 java/6
 24127 oasis    2.5 0.2 0.0 0.0 0.0 1.5  65 0.0  22  26 124   0 java/12
 24127 oasis    2.4 0.2 0.0 0.0 0.0 1.3  65 0.0  22  26 122   0 java/9
 24127 oasis    2.4 0.2 0.0 0.0 0.0 1.2  65 0.0  22  26 124   0 java/15
 24127 oasis    2.4 0.2 0.0 0.0 0.0 1.2  65 0.0  22  26 123   0 java/5
 24127 oasis    2.3 0.2 0.0 0.0 0.0 1.1  65 0.0  20  25 115   0 java/16
 24127 oasis    2.2 0.2 0.0 0.0 0.0 1.2  65 0.0  21  24 115   0 java/7
  3085 oasis    2.4 0.0 0.0 0.0 0.0 0.0  98 0.0   2   9  11   0 java/486
 24127 oasis    2.2 0.2 0.0 0.0 0.0 1.1  66 0.0  20  23 110   0 java/10
 24127 oasis    1.9 0.2 0.0 0.0 0.0 0.0  66 0.0  18  20  98   0 java/14
 24127 oasis    1.6 0.1 0.0 0.0 0.0 0.0  66 0.0  15  17  83   0 java/11
  8606 oasis    1.6 0.0 0.0 0.0 0.0 0.0  98 0.0   4   6  36   0 java/135
  3357 oasis    1.5 0.1 0.0 0.0 0.0 0.0  50 0.0   0   7  37   0 java/51
 24127 oasis    1.4 0.1 0.0 0.0 0.0 1.3  66 0.0  13  15  70   0 java/13
  3085 oasis    1.3 0.0 0.0 0.0 0.0 0.0  99 0.0   1   4   7   0 java/479
  3086 oasis    1.2 0.0 0.0 0.0 0.0 0.0  99 0.0   1   9   5   0 java/366
  8606 oasis    1.2 0.0 0.0 0.0 0.0 0.0  99 0.0   6   2  45   0 java/132
 19318 oasis    0.9 0.2 0.0 0.0 0.0 0.0  53 0.0   3   3  40   0 java/42
  3085 oasis    1.0 0.0 0.0 0.0 0.0 0.0  57 0.0   1   4  11   0 java/459
 14224 oasis    0.7 0.3 0.0 0.0 0.0 0.0  63 0.0   5   1  75   0 java/562
  3085 oasis    1.0 0.0 0.0 0.0 0.0 0.0  68 0.0   7   4  17   0 java/450
  3354 oasis    0.9 0.1 0.0 0.0 0.0 0.0  61 0.0   0   2  24   0 java/9
  8606 oasis    0.8 0.1 0.0 0.0 0.0 0.0  72 0.0  10   2  19   0 java/14
  3086 oasis    0.9 0.0 0.0 0.0 0.0 0.0  57 0.0   4   3   6   0 java/350
  3085 oasis    0.8 0.0 0.0 0.0 0.0 0.0  52 0.0   6   4   6   0 java/328
 19318 oasis    0.8 0.0 0.0 0.0 0.0 0.0  54 0.0   6   2  12   0 java/4
  3085 oasis    0.7 0.0 0.0 0.0 0.0 0.0  63 0.0   9   8   7   0 java/474
  3086 oasis    0.7 0.0 0.0 0.0 0.0 0.0  62 0.0   4   6   5   0 java/353
  8606 oasis    0.7 0.0 0.0 0.0 0.0 0.0  99 0.0   5   0  31   0 java/141
  6435 oasis    0.7 0.0 0.0 0.0 0.0 0.0  99 0.0   2   3  14   0 java/131
 19318 oasis    0.5 0.1 0.0 0.0 0.0 2.1  52 0.0   5   2  29   0 java/10
  5491 mqm      0.3 0.3  -   -   -   -  100  -    6   0  42   0 amqzlaa0_nd/48
 29231 pkodav   0.0 0.6  -   -   -   -   52  -    8   0  34   3 File/1
  3156 rravee   0.0 0.6  -   -   -   -   52  -    8   0  34   3 Track/1
 21075 mvelur   0.0 0.6  -   -   -   -   52  -    8   0  34   3 Track/1
  3085 oasis    0.6 0.0 0.0 0.0 0.0 0.0  74 0.0   6   2   6   0 java/440
   524 root     0.0 0.5  -   -   -   -   69  -    0   0   4   0 automountd/1036
  3085 oasis    0.5 0.0 0.0 0.0 0.0 0.0  74 0.0   6   2   4   0 java/442
 20448 mqm      0.2 0.3  -   -   -   -   54  -   40   6 236   0 amqrmppa/11
  8606 oasis    0.5 0.0 0.0 0.0 0.0 0.0  99 0.0   3   1  33   0 java/137
Total: 524 processes, 5724 lwps, load averages: 2.11, 1.59, 2.45 "

but when i use
prstat -mvL 1 1 | awk -F" " '{print $1,$15}'

i just get
"
Code:
PID PROCESS/LWPID
1331 prstat/1
3086 java/4
3085 java/4
1327 vi/1
24127 java/8
24127 java/6
1332 awk/1
24127 java/12
24127 java/9
24127 java/15
24127 java/5
24127 java/16
24127 java/7
24127 java/10
3085 java/486"


Why is there a difference showing the number of PID's when i use simply and when i use awk.I am just printing 1st and 15th args??

Thanks
# 4  
Old 04-01-2009
from prstat manpage:

Code:
 By  default,
                          prstat displays as many lines of output
                          that  fit in a window or terminal. When
                          you specify the -c option or direct the
                          output  to  a  file, the default values
                          for ntop and nbottom are 15 and 5.

so....you need to use something like:

Code:
#   prstat -n 60 -mvL 1 1 |  awk -F" " '{print $1,$15}'

HTH
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is wrong with my awk command?

The below code usually works when the value for the COLUMN variable is numerical. but im in a situation where the number of fields in a file is not definitive. it changes. but what is static is that the value i want to retrieve from the log is 3 fields from the last field. which is what i... (9 Replies)
Discussion started by: SkySmart
9 Replies

2. UNIX for Dummies Questions & Answers

VxWorks RTC time giving wrong value at random times

I am seeing a scenario where in if the TIMEZONE environment variable value is set to nothing i.e. putenv "TIMEZONE=" the hardware clock is +1 to software clock.Pasted below the results displayed: -> envShow (global environment) 0: TSC_TIME_FROM_RESET=420150.971529 seconds 1:... (0 Replies)
Discussion started by: snehavb
0 Replies

3. Shell Programming and Scripting

If && command giving wrong output

Hi All, I am trying to run a script which will search for 2 strings(stopped,started) in a text file and echo an output depending on below condition -bash-3.2$ cat trial1.txt v ggg f -bash-3.2$ cat trial1.sh VAR9=` grep 'stopped' /tmp/trial1.txt` VAR10=` grep 'started'... (4 Replies)
Discussion started by: srkmish
4 Replies

4. Shell Programming and Scripting

Number comparison in ksh on mac with -lt is giving wrong answer

I am trying to run following script in ksh on darwin 11.4.2: freeSpace=2469606195 spaceNeeded=200 ] && echo "no space" || echo "space available" ] && echo "no space" || echo "space available" "-lt" is giving wrong answer as "no space" Whereas '<' works fine. When I change the freespace... (4 Replies)
Discussion started by: sabitha
4 Replies

5. UNIX for Advanced & Expert Users

xbindkeys giving wrong mapping information

Hello, I'm having a problem with xbindkeys giving the wrong mapping information, hence I can't get it work at all when trying new mappings from this machine. From another computer, I have some definitions for xbindkeys (made with xbindkeys-config). These key codes work correctly on this... (0 Replies)
Discussion started by: Narnie
0 Replies

6. Emergency UNIX and Linux Support

getting wrong output with AWK command!!!

i have a file which gets appended with 9 records daily and the file keeps growing from then...i use to store the previous day files count in a variable called oldfilecount and current files count as newfilecount.my requirement is that i need to start processing only the new records from the... (3 Replies)
Discussion started by: ganesh_248
3 Replies

7. Shell Programming and Scripting

tr command giving wrong output

Hi All, i have a file which have many fields delimited by ,(comma) now i have to show only few fields and not all. the sample text file looks like this: TYPE=SERVICEEVENT, TIMESTAMP=05/06/2009 11:01:40 PM, HOST=sppwa634, APPLICATION=ASComp, FUNCTION=LimitsService, SOU... (8 Replies)
Discussion started by: usha rao
8 Replies

8. Shell Programming and Scripting

Sort command giving wrong output

Hi all, I have a problem with sort command. i have a file which looks like this: "file1 1073 java/4 1073 java/180 1073 java/170 1073 java/176 1073 java/167 1073 java/40 1073 java/33 1073 java/136 28988 java/76 28988 java/73 28988 java/48 28988 java/26" and i want to sort... (8 Replies)
Discussion started by: usha rao
8 Replies

9. AIX

Shared memory giving wrong value

Hi , I am working on AIX 5.3 server.I have small program which stores the from database to a particaular shared memory.But while retreiving the valus from the same shared memory, i am getting wrong values. Please help..... (1 Reply)
Discussion started by: ajaysahoo
1 Replies

10. Shell Programming and Scripting

Script giving wrong results....

hi, I have this script which gives me the result... #! /usr/bin/sh set -x cd /home/managar a=1 while true do if then echo " File log.txt exists in this directory " exit 0 fi echo " File has not arrived yes..." sleep 3 let a=a+1 if then (1 Reply)
Discussion started by: mgirinath
1 Replies
Login or Register to Ask a Question