Sponsored Content
Top Forums UNIX for Dummies Questions & Answers awk adding counts together from column Post 302847423 by aniquebmx on Tuesday 27th of August 2013 03:16:14 AM
Old 08-27-2013
values corrected ie 38 + 47 = 85 sorry got in a mess trying to put in code brackets
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

problem while adding column values in awk

Hi, I have a file "input.txt" with the following content : 5312,0,,,1,8,141.2,20090727 3714,0,,,1,8,285.87,20090727 5426,0,,,1,8,3.9,20090727 3871,0,,,1,8,30.4,20090727 9071,0,,,1,8,146.2,20090727 5141,0,,,1,8,2.8,20090727 0460,0,,,1,8,-0.1,20090727 7918,0,,,1,8,-0.1,20090727... (3 Replies)
Discussion started by: valokv
3 Replies

2. Shell Programming and Scripting

awk-adding a column to a file

Hello Friends, i used awk to sum up total size of files under a directory (with the help of examples, threads here). ls -l | awk '/^-/ {total += $5} END {printf "%15.0f\n",total}' >> total.txt After each execution of the script total result is appended into a text file: 7010 7794 8890 ... (7 Replies)
Discussion started by: EAGL€
7 Replies

3. Shell Programming and Scripting

sed/awk-adding numeric to a column

I have a txt file as follows Code: Oct 1 file1 4144 Oct 1 file23 5170 Oct 2 file5 3434 Oct 21 file56 2343 I need to add a new column by marking the right log file from current directory. For example populate like this. Please not in the second columt for "1" it has... (2 Replies)
Discussion started by: gubbu
2 Replies

4. UNIX for Dummies Questions & Answers

Adding a column with the row number using awk

Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
Discussion started by: cosmologist
4 Replies

5. UNIX for Dummies Questions & Answers

how to get distinct counts in a column of a file

If i have a file sample.txt with more than 10 columns and 11th column as following data. would it be possible to get the distinct counts of values in single shot,Thank you. Y Y N N N P P o Expected Result: Value count Y 2 N 3 P 2 (2 Replies)
Discussion started by: Ariean
2 Replies

6. Shell Programming and Scripting

Adding column using awk

Hello everyone, I have a file with the following structure: abc xyz 111 222 agf hjhf 787 799 tht yah 878 898 ... ... ... ... ... ... ... ... ... ... ... ... I want to add a column (with a fixed value of 1000) at the end such that it becomes: abc xyz 111 222 1000 agf hjhf 787... (5 Replies)
Discussion started by: ad23
5 Replies

7. Linux

Adding a prefix to a column using awk/sed commands

Hello, I am a newbie to linux and struggling to find a better way to append a column in a text file. Here is the file i want to modify: It has 8 columns (and thousands of rows). I want to append the first column by adding "chr" infront of the numbers. Some rows have a string in the first... (4 Replies)
Discussion started by: bjorngill
4 Replies

8. Shell Programming and Scripting

Filtering lines for column elements based on corresponding counts in another column

Hi, I have a file like this ACC 2 2 21 aaa AC 443 3 22 aaa GCT 76 1 33 xxx TCG 34 2 33 aaa ACGT 33 1 22 ggg TTC 99 3 44 wee CCA 33 2 33 ggg AAC 1 3 55 ddd TTG 10 1 22 ddd TTGC 98 3 22 ddd GCT 23 1 21 sds GTC 23 4 32 sds ACGT 32 2 33 vvv CGT 11 2 33 eee CCC 87 2 44... (1 Reply)
Discussion started by: polsum
1 Replies

9. Shell Programming and Scripting

Adding a specified value to a specified column - awk?

Hi everyone! I sometimes need to do some simple arithmetics, like adding a number to a certain column of a file. So I wrote a small function in the .bashrc file, which looks like this shifter() { COL=$1 VAL=$2 FILE=$3 cp $FILE $FILE.shifted awk 'NF==4 {$(( $COL )) = $(( $COL ))... (6 Replies)
Discussion started by: radudownload
6 Replies

10. UNIX for Dummies Questions & Answers

Des/awk for change format and adding integers in a column of data?

Greetings! I need a quick way to change the format in a table of data Here is an example of the input: 10 72 Value=177 VDB=0.0245 Value4=0,0,171,0 10 274 Value=238 VDB=0.0433 Value4=29,0,205,0 10 312 Value=222 VDB=0.0384 Value4=8,0,190,19 10 540 Value=405 VDB=0.0391 Value4=13,30,153,195... (3 Replies)
Discussion started by: Twinklefingers
3 Replies
HTTP::Message(3)					User Contributed Perl Documentation					  HTTP::Message(3)

NAME
HTTP::Message - HTTP style message (base class) SYNOPSIS
use base 'HTTP::Message'; DESCRIPTION
An "HTTP::Message" object contains some headers and a content body. The following methods are available: $mess = HTTP::Message->new $mess = HTTP::Message->new( $headers ) $mess = HTTP::Message->new( $headers, $content ) This constructs a new message object. Normally you would want construct "HTTP::Request" or "HTTP::Response" objects instead. The optional $header argument should be a reference to an "HTTP::Headers" object or a plain array reference of key/value pairs. If an "HTTP::Headers" object is provided then a copy of it will be embedded into the constructed message, i.e. it will not be owned and can be modified afterwards without affecting the message. The optional $content argument should be a string of bytes. $mess = HTTP::Message->parse( $str ) This constructs a new message object by parsing the given string. $mess->headers Returns the embedded "HTTP::Headers" object. $mess->headers_as_string $mess->headers_as_string( $eol ) Call the as_string() method for the headers in the message. This will be the same as $mess->headers->as_string but it will make your program a whole character shorter :-) $mess->content $mess->content( $bytes ) The content() method sets the raw content if an argument is given. If no argument is given the content is not touched. In either case the original raw content is returned. Note that the content should be a string of bytes. Strings in perl can contain characters outside the range of a byte. The "Encode" module can be used to turn such strings into a string of bytes. $mess->add_content( $bytes ) The add_content() methods appends more data bytes to the end of the current content buffer. $mess->add_content_utf8( $string ) The add_content_utf8() method appends the UTF-8 bytes representing the string to the end of the current content buffer. $mess->content_ref $mess->content_ref( $bytes ) The content_ref() method will return a reference to content buffer string. It can be more efficient to access the content this way if the content is huge, and it can even be used for direct manipulation of the content, for instance: ${$res->content_ref} =~ s/foo/bar/g; This example would modify the content buffer in-place. If an argument is passed it will setup the content to reference some external source. The content() and add_content() methods will automatically dereference scalar references passed this way. For other references content() will return the reference itself and add_content() will refuse to do anything. $mess->content_charset This returns the charset used by the content in the message. The charset is either found as the charset attribute of the "Content-Type" header or by guessing. See http://www.w3.org/TR/REC-html40/charset.html#spec-char-encoding <http://www.w3.org/TR/REC-html40/charset.html#spec-char-encoding> for details about how charset is determined. $mess->decoded_content( %options ) Returns the content with any "Content-Encoding" undone and the raw content encoded to perl's Unicode strings. If the "Content-Encoding" or "charset" of the message is unknown this method will fail by returning "undef". The following options can be specified. "charset" This override the charset parameter for text content. The value "none" can used to suppress decoding of the charset. "default_charset" This override the default charset guessed by content_charset() or if that fails "ISO-8859-1". "charset_strict" Abort decoding if malformed characters is found in the content. By default you get the substitution character ("x{FFFD}") in place of malformed characters. "raise_error" If TRUE then raise an exception if not able to decode content. Reason might be that the specified "Content-Encoding" or "charset" is not supported. If this option is FALSE, then decoded_content() will return "undef" on errors, but will still set $@. "ref" If TRUE then a reference to decoded content is returned. This might be more efficient in cases where the decoded content is identical to the raw content as no data copying is required in this case. $mess->decodable HTTP::Message::decodable() This returns the encoding identifiers that decoded_content() can process. In scalar context returns a comma separated string of identifiers. This value is suitable for initializing the "Accept-Encoding" request header field. $mess->decode This method tries to replace the content of the message with the decoded version and removes the "Content-Encoding" header. Returns TRUE if successful and FALSE if not. If the message does not have a "Content-Encoding" header this method does nothing and returns TRUE. Note that the content of the message is still bytes after this method has been called and you still need to call decoded_content() if you want to process its content as a string. $mess->encode( $encoding, ... ) Apply the given encodings to the content of the message. Returns TRUE if successful. The "identity" (non-)encoding is always supported; other currently supported encodings, subject to availability of required additional modules, are "gzip", "deflate", "x-bzip2" and "base64". A successful call to this function will set the "Content-Encoding" header. Note that "multipart/*" or "message/*" messages can't be encoded and this method will croak if you try. $mess->parts $mess->parts( @parts ) $mess->parts( @parts ) Messages can be composite, i.e. contain other messages. The composite messages have a content type of "multipart/*" or "message/*". This method give access to the contained messages. The argumentless form will return a list of "HTTP::Message" objects. If the content type of $msg is not "multipart/*" or "message/*" then this will return the empty list. In scalar context only the first object is returned. The returned message parts should be regarded as read-only (future versions of this library might make it possible to modify the parent by modifying the parts). If the content type of $msg is "message/*" then there will only be one part returned. If the content type is "message/http", then the return value will be either an "HTTP::Request" or an "HTTP::Response" object. If an @parts argument is given, then the content of the message will be modified. The array reference form is provided so that an empty list can be provided. The @parts array should contain "HTTP::Message" objects. The @parts objects are owned by $mess after this call and should not be modified or made part of other messages. When updating the message with this method and the old content type of $mess is not "multipart/*" or "message/*", then the content type is set to "multipart/mixed" and all other content headers are cleared. This method will croak if the content type is "message/*" and more than one part is provided. $mess->add_part( $part ) This will add a part to a message. The $part argument should be another "HTTP::Message" object. If the previous content type of $mess is not "multipart/*" then the old content (together with all content headers) will be made part #1 and the content type made "multipart/mixed" before the new part is added. The $part object is owned by $mess after this call and should not be modified or made part of other messages. There is no return value. $mess->clear Will clear the headers and set the content to the empty string. There is no return value $mess->protocol $mess->protocol( $proto ) Sets the HTTP protocol used for the message. The protocol() is a string like "HTTP/1.0" or "HTTP/1.1". $mess->clone Returns a copy of the message object. $mess->as_string $mess->as_string( $eol ) Returns the message formatted as a single string. The optional $eol parameter specifies the line ending sequence to use. The default is " ". If no $eol is given then as_string will ensure that the returned string is newline terminated (even when the message content is not). No extra newline is appended if an explicit $eol is passed. $mess->dump( %opt ) Returns the message formatted as a string. In void context print the string. This differs from "$mess->as_string" in that it escapes the bytes of the content so that it's safe to print them and it limits how much content to print. The escapes syntax used is the same as for Perl's double quoted strings. If there is no content the string "(no content)" is shown in its place. Options to influence the output can be passed as key/value pairs. The following options are recognized: maxlength => $num How much of the content to show. The default is 512. Set this to 0 for unlimited. If the content is longer then the string is chopped at the limit and the string "... (### more bytes not shown)" appended. prefix => $str A string that will be prefixed to each line of the dump. All methods unknown to "HTTP::Message" itself are delegated to the "HTTP::Headers" object that is part of every message. This allows convenient access to these methods. Refer to HTTP::Headers for details of these methods: $mess->header( $field => $val ) $mess->push_header( $field => $val ) $mess->init_header( $field => $val ) $mess->remove_header( $field ) $mess->remove_content_headers $mess->header_field_names $mess->scan( &doit ) $mess->date $mess->expires $mess->if_modified_since $mess->if_unmodified_since $mess->last_modified $mess->content_type $mess->content_encoding $mess->content_length $mess->content_language $mess->title $mess->user_agent $mess->server $mess->from $mess->referer $mess->www_authenticate $mess->authorization $mess->proxy_authorization $mess->authorization_basic $mess->proxy_authorization_basic COPYRIGHT
Copyright 1995-2004 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.1 2009-11-21 HTTP::Message(3)
All times are GMT -4. The time now is 04:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy