This awk should work, shouldn't it?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers This awk should work, shouldn't it?
# 15  
Old 09-28-2015
Guess the NR=3 tells awk to jut parse the third line, and in this case could be replaced by END - as it seemed.
Might i ask why you've chosen $39 instead of $27 (as i did, first found)?
Is there any difference?

Thank you

---------- Post updated at 14:31 ---------- Previous update was at 14:29 ----------

@ RudiC:
Code:
0 tui # cat out.tmp 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  4 81.5^C
130 tui # awk -vRS="^M" '{print $2}' ./out.tmp
Total
0 tui # awk -v RS="^M" '{print $2}' ./out.tmp
Total

Smilie
# 16  
Old 09-28-2015
AGAIN: post a hexdump!
# 17  
Old 09-28-2015
Regular:
Code:
cat out.tmp 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 30 81.5M   30 24.8M    0     0  2818k      0  0:00:29  0:00:09  0:00:20 4305k

Hexdump:
Code:
hexdump out.tmp 
0000000 2020 2025 6f54 6174 206c 2020 2520 5220
0000010 6365 6965 6576 2064 2025 6658 7265 2064
0000020 4120 6576 6172 6567 5320 6570 6465 2020
0000030 5420 6d69 2065 2020 5420 6d69 2065 2020
0000040 2020 6954 656d 2020 7543 7272 6e65 0a74
0000050 2020 2020 2020 2020 2020 2020 2020 2020
*
0000070 4420 6f6c 6461 2020 7055 6f6c 6461 2020
0000080 5420 746f 6c61 2020 5320 6570 746e 2020
0000090 2020 654c 7466 2020 7053 6565 0a64 200d
00000a0 3020 2020 2020 3020 2020 2020 2030 2020
00000b0 2020 2030 2020 3020 2020 2020 3020 2020
00000c0 2020 2020 2030 2020 2020 3020 2d20 3a2d
00000d0 2d2d 2d3a 202d 2d2d 2d3a 3a2d 2d2d 2d20
00000e0 3a2d 2d2d 2d3a 202d 2020 2020 0d30 2020
00000f0 2030 2020 2020 2030 2020 3020 2020 2020
0000100 3020 2020 2020 2030 2020 2020 2030 2020
0000110 2020 3020 2020 2020 2020 2030 2d2d 2d3a
0000120 3a2d 2d2d 2d20 3a2d 2d2d 2d3a 202d 2d2d
0000130 2d3a 3a2d 2d2d 2020 2020 3020 200d 3020
0000140 3820 2e31 4d35 2020 2020 2030 3032 3230
0000150 2034 2020 3020 2020 2020 3020 2020 3831
0000160 3732 2039 2020 2020 3020 2020 3a31 3731
0000170 353a 2038 3020 303a 3a30 3130 2020 3a31
0000180 3731 353a 2037 3831 3732 0d30 2020 2030
0000190 3138 352e 204d 2020 3020 2020 3932 6b30
00001a0 2020 2020 2030 2020 2020 2030 2020 3431
00001b0 6b32 2020 2020 2020 2030 3020 303a 3a39
00001c0 3534 2020 3a30 3030 303a 2032 3020 303a
00001d0 3a39 3334 2020 3431 6b32 200d 3120 3820
00001e0 2e31 4d35 2020 2020 2031 3131 3632 206b
00001f0 2020 3020 2020 2020 3020 2020 3320 3037
0000200 206b 2020 2020 3020 2020 3a30 3330 343a
0000210 2035 3020 303a 3a30 3330 2020 3a30 3330
0000220 343a 2032 3320 3037 0d6b 2020 2034 3138
0000230 352e 204d 2020 3420 3420 3130 6b38 2020
0000240 2020 2030 2020 2020 2030 2020 3939 6b32
0000250 2020 2020 2020 2030 3020 303a 3a31 3432
0000260 2020 3a30 3030 303a 2034 3020 303a 3a31
0000270 3032 2020 3939 6b31 200d 3031 3820 2e31
0000280 4d35 2020 3120 2030 3338 3839 206b 2020
0000290 3020 2020 2020 3020 2020 3631 3932 206b
00002a0 2020 2020 3020 2020 3a30 3030 353a 2031
00002b0 3020 303a 3a30 3530 2020 3a30 3030 343a
00002c0 2036 3631 3833 0d6b 3120 2034 3138 352e
00002d0 204d 2020 3431 3120 2e31 4d39 2020 2020
00002e0 2030 2020 2020 2030 3220 3330 6b36 2020
00002f0 2020 2020 2030 3020 303a 3a30 3134 2020
0000300 3a30 3030 303a 2036 3020 303a 3a30 3533
0000310 3220 3834 6b35 200d 3032 3820 2e31 4d35
0000320 2020 3220 2030 3631 352e 204d 2020 3020
0000330 2020 2020 3020 2020 3432 3930 206b 2020
0000340 2020 3020 2020 3a30 3030 333a 2034 3020
0000350 303a 3a30 3730 2020 3a30 3030 323a 2037
0000360 3333 3433 0d6b 3220 2034 3138 352e 204d
0000370 2020 3432 3220 2e30 4d32 2020 2020 2030
0000380 2020 2020 2030 3220 3835 6b33 2020 2020
0000390 2020 2030 3020 303a 3a30 3233 2020 3a30
00003a0 3030 303a 2038 3020 303a 3a30 3432 3320
00003b0 3339 6b31 200d 3033 3820 2e31 4d35 2020
00003c0 3320 2030 3432 382e 204d 2020 3020 2020
00003d0 2020 3020 2020 3832 3831 206b 2020 2020
00003e0 3020 2020 3a30 3030 323a 2039 3020 303a
00003f0 3a30 3930 2020 3a30 3030 323a 2030 3334
0000400 3530 006b                              
0000403

# 18  
Old 09-28-2015
Quote:
Originally Posted by sea
Guess the NR=3 tells awk to jut parse the third line, and in this case could be replaced by END - as it seemed.
Might i ask why you've chosen $39 instead of $27 (as i did, first found)?
Is there any difference?
Thank you
Hello sea,

If you see output carefully posted by you then you will see as follows, posting some portion of output.
Code:
31 0
32 14343
33 0
34 1:39:22
35 0:00:01
36 1:39:21
37 14343
38 0
39 81.5M

So here 39 means the field number and after that it's value, also it is 3rd line, so only printed like that.


Thanks,
R. Singh
# 19  
Old 09-28-2015
@ Ravinder: Figured that too Smilie
My question is more like if there is any specific reason, or did you just start from bottom? Smilie
Code:
25 0
26 0
27 81.5M
28 0
29 20024
30 0
31 0
32 14343
33 0
34 1:39:22
35 0:00:01
36 1:39:21
37 14343
38 0
39 81.5M
40 0

Thank you
# 20  
Old 09-28-2015
Did you enter literal "^M" or did you use the <CR> control character (e.g. <Ctrl V><Ctrl M>, or "\r") ?
# 21  
Old 09-28-2015
Sorry sea, my bad didn't see previous value. I am sorry, you can use the field appropriate to your need to print I can say Smilie.

Thanks,
R. Singh
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Why does this if match although it shouldn't?

Hi everyboy, I am a little confused and can't understand why I get a positive match in the following case. Shell Script section echo $SHELL echo "Server type = ${SERV_TYPE}" if ]]; then echo "foor" echo -e $(_date) "${cinfo}INFO: ${crst}Checking SAP memory on ${HOST}"This is the... (1 Reply)
Discussion started by: h1kelds
1 Replies

2. UNIX for Dummies Questions & Answers

Users of own group shouldn't be able to delete

Oracle Linux 6.5 oracle user's primary group is oinstall and its secondary group is dba,asmdba,asmoper. For the below created directory, I want the users belonging to dba,asmdba,asmoper to be able create, read and execute files but not delete them. How can I achieve that. If I use 775 as... (5 Replies)
Discussion started by: kraljic
5 Replies

3. Shell Programming and Scripting

Script outputing out numbers when it shouldn't

i suspect the issue is with the IFS part. I have a script that reads a file. the problem here is that, when i run the script, it outputs a bunch of numbers. i know what these numbers are, but i dont understand why they're being sent to the screen. as you can see below, everything should be... (5 Replies)
Discussion started by: SkySmart
5 Replies

4. Solaris

Particular user account shouldn't be locked after entering wrong passwd specfic no. times

Hi all In my system we have implemented user lockout feature after 3 failure attempt if he tries to login directly or if he run the any command through sudo and enter wrong password thrice. Now I have requirement in which particular user account shouldn't be locked when he run the command... (1 Reply)
Discussion started by: sb200
1 Replies

5. Shell Programming and Scripting

Delimited data contains line feeds where they shouldn't be

I have some data, each record (line) ends with a line feed (\n). Each field is pipe (|) delimited. 1|short desc|long text|2001-01-01 01:01 2|short desc| long text |2002-02-02 02:02 3|short desc| long text | 2003-03-03 03:03 4|short desc | long text | 2004-04-04 04:04 ... (10 Replies)
Discussion started by: ericdp63
10 Replies

6. Shell Programming and Scripting

Parse file using awk and work in awk output

hi guys, i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 this the file raw format: Number of... (6 Replies)
Discussion started by: dagigg
6 Replies

7. Shell Programming and Scripting

awk: assign variable with -v didn't work in awk filter

I want to filter 2nd column = 2 using awk $ cat t 1 2 2 4 $ VAR=2 #variable worked in print $ cat t | awk -v ID=$VAR ' { print ID}' 2 2 # but variable didn't work in awk filter $ cat t | awk -v ID=$VAR '$2~/ID/ { print $0}' (2 Replies)
Discussion started by: honglus
2 Replies

8. Shell Programming and Scripting

why awk does not work here?

I am trying to find any line with the 9th column's number greater than 200, but why the following awk command does not work? awk '$9 > 200' /tmp/test 2007-09-05 10:13:05.714 640.847 any 1.2.3.4 719 2445 487260 32 6082 199 2007-09-05 10:13:02.686 641.827... (2 Replies)
Discussion started by: fedora
2 Replies

9. UNIX for Dummies Questions & Answers

why is this so hard when it shouldn't be?

All I ask is one thing: 1. Where can i dl unix and the driver for my modem? right now i have win xp HP notebook, and bellsouth is my provider with a westell modem. (2 Replies)
Discussion started by: velious
2 Replies
Login or Register to Ask a Question