process text file with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting process text file with awk
# 1  
Old 02-02-2009
process text file with awk

I have a text file which represent a http packet:
header1
haeder2
.....
.....
headern

payload

I need to count bytes in the payload. How can I get it using awk?
Thanks in advance
Andrea Musella
# 2  
Old 02-02-2009
An original output as example could help helping you.
# 3  
Old 02-02-2009
I insert an example of file which i want to process:
Code:
HTTP/1.1 200 OK

Date: Fri, 23 Jan 2009 17:16:24 GMT

Server: Apache

Last-Modified: Fri, 23 Jan 2009 17:08:03 GMT

Accept-Ranges: bytes

Cache-Control: max-age=540

Expires: Fri, 23 Jan 2009 17:21:31 GMT

Vary: Accept-Encoding

Content-Encoding: gzip

Age: 233

Content-Length: 1276

Keep-Alive: timeout=1, max=198

Connection: Keep-Alive

Content-Type: application/x-javascript



...........Wmo.6.........r\Y/..8.S.+2......aK...eq.E...7A....(Q.......y...=w|...:>2.?....0.1C+.a.0..t..E..<.>>B.`.....[.......3....@|7.C.AS......=d...&.G......>...K.....=o-....J|.e..df,Dg5.4...>..8L.!$..]....<e..T.Or...q.......R-U._2q9e....#...........ZG..j
........llZ...h^o..
vi.%...dn/.O....(...H.....ud..)...#k.t.......Y.t0R-.d...Ff.yQ._5.....z..a.B"(T0.....U..O.....P$.9.f..N.ID.v]$..m..).l..|q]E0.
..bj*.].^.l................9..Z.3..mp..|U......b...^;....&.=.

I want the count of bytes represented by text after the last header (Content-type)

Last edited by zaxxon; 02-02-2009 at 12:47 PM.. Reason: added code-tags
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process text file to create CSV

I am working on a text file where I have to get data from a text file and convert it into either CSV format or Column format as shown below. OUTPUT Expected GRP Name Pair Size DName DNumber PName PNumber adm_grp Pair1 150.00KG Pair_0ABC_1 0396 Pair_0267_s 1292 ... (6 Replies)
Discussion started by: shunya
6 Replies

2. UNIX for Advanced & Expert Users

Using awk to read a file and process

I am fairly green using awk so I don't have anything started but what I am trying to do is: I have a file called "contacts" and in the file are 3 fields separate by ;. I want to read each line and send an email script. I have the email function working but just need to know how to setup awk to... (8 Replies)
Discussion started by: ziggy6
8 Replies

3. Shell Programming and Scripting

Process multiple lines in a text file

Hi All I have text file like this: a=21ej c=3tiu32 e=hydkehw f=hgdiuw g=jhdkj a=klkjhvl b=dlkjhyfd a=yo c=8732 Any way I can process data from first a to just before of second a, and then second a to just before of 3rd one. Just fetching records like that will help, I mean... (3 Replies)
Discussion started by: sandipjee
3 Replies

4. Shell Programming and Scripting

Perl: How to read text from file and process $variable in that data too.

In the hello.htm have the sentenses: Hello $name How are you? The perl script: $name = "David"; open(HEADER,"hello.htm"); while(<HEADER>) { $html .= $_; } close(HEADER); print "$html";I making something about template. But it can't process the $name variable. (4 Replies)
Discussion started by: natong
4 Replies

5. Shell Programming and Scripting

search text file in file if this file contains necessary text (awk,grep)

Hello friends! Help me pls to write correct awk and grep statements for my task: I have got files with name filename.txt It has such structure: Start of file FROM: address@domen.com (12...890) abc DATE: 11/23/2009 on Std SUBJECT: any subject End of file So, I must check, if this file... (4 Replies)
Discussion started by: candyme
4 Replies

6. Shell Programming and Scripting

Need advise to process the file with awk

Hi gurus, i need your advise on how to process this file using awk. i have this file COLA COLB COLC COLD COLE COLF COLG COLH AAAA 86 111 122 133 144 155 266 377 BBBB 70 211 222 233 244 255 266 ... (6 Replies)
Discussion started by: ablanc
6 Replies

7. Shell Programming and Scripting

How to make AWK process an input file many many times?

By "many many times" I mean the times the input file is to be processed is unknown beforehand, it will be known when awk finishes processing the input file for the first time. So my question is: how to start over again from the first record of the input file when AWK finishes processing the... (7 Replies)
Discussion started by: kevintse
7 Replies

8. Shell Programming and Scripting

awk: process file

Hello, i have a file as below: ... AAA: 1 BBB: 2 CCC: 3 AAA: 11 BBB: 22 CCC: 33 AAA: 111 BBB: 222 CCC: 333 .... how to process it by using AWK to this: (AAA BBB CCC) .... 1 11 111 2 22 222 3 33 333 (2 Replies)
Discussion started by: 0916981
2 Replies

9. Shell Programming and Scripting

Need help with a script to process a CSV file using SED and AWK

I get a CSV file every day with 2 columns and multiple rows ex: date1,date2 ( both the fields are varchar fields) This data has to be updated in a table which is being done manually and i want to automate that. 1. I have to select all the data from the prod table( 2 columns { date1,date2}) into... (4 Replies)
Discussion started by: kkb
4 Replies
Login or Register to Ask a Question