Sponsored Content
Full Discussion: awk to format an output
Top Forums Shell Programming and Scripting awk to format an output Post 302526388 by getmmg on Tuesday 31st of May 2011 11:04:31 AM
Old 05-31-2011
If perl is okay, then you can use the following code.

Code:
 
perl -F, -lane 'if($#F == 0){$time=$_}else{$hash{$time}+=$F[1]+$F[2] if($F[0]!~/ed/)} END{print $_.",".$hash{$_} for sort keys %hash}' d
Fri May 13 10:29:16 2011,3.4
Fri May 13 10:39:16 2011,3.3
Fri May 13 10:49:16 2011,5

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output in a particular format using AWK

Hi All, I am trying to check if if column 5 is greater than 90. If greater it will print the term in column 6, else if all are within limit, then it will output "Size is within limit". I can't seem to do that with the below code. The output should only be 1 statement of "Size is within the... (4 Replies)
Discussion started by: Raynon
4 Replies

2. Shell Programming and Scripting

[need help] output format from awk

hi all, i have a problem with my nawk command output below is the description : nawk $12 == "00008001" { cnt++;cs_cd } END {for(cd in cs_cd) print cd, cs_cd } 2007020814.TDR output : 133 123 desire output: 133,123,.... please advices thank you so much (6 Replies)
Discussion started by: bucci
6 Replies

3. Shell Programming and Scripting

Awk output format help!!! Urgent!!!!

Hello!! I am capturing and counting certain uniq occurance of certain evet from large log files. below is my output I m getting with my script: No of Messages Date Hour 150 Aug15 1 234 Aug15 2 345 Aug15 3 . ... (4 Replies)
Discussion started by: namodi
4 Replies

4. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

5. Shell Programming and Scripting

awk - format output

Input file1 zone: BAU_SERVER1 C0:50:76:01:C6:20:00:12; 50:06:01:69:3B:20:14:8B; 50:06:01:60:3B:20:14:8B zone: BAU_SERVER2 C0:50:76:01:C6:20:00:08; 50:06:01:69:3B:20:14:8B; 50:06:01:60:3B:20:14:8B zone: ... (4 Replies)
Discussion started by: greycells
4 Replies

6. UNIX for Dummies Questions & Answers

after awk-> format output

hi i have a awk command with several querys.... awk 'FS="|""; print $4, $5, $6...etc.... $4 gives me the date 20120304 $5 is timestamp 101023 I want to format these in 2012.03.04 or 2012/03/04 10:10:23 but have no idea, if this is possible with format-parameters in the awk... (2 Replies)
Discussion started by: Jazzmatazz
2 Replies

7. Shell Programming and Scripting

Using AWK to format output and email

Hello, I'm a bit stumped, for some reason when using AWK 'print' is not printing the entire date/line. awk '{print "Ticket #: " $1} {print "Queue : " $2} {print "Recieved : " $3} {print "AP Date : " $4} {print "Circuit ID : " $5} {print... (4 Replies)
Discussion started by: ArvinSodhi
4 Replies

8. Shell Programming and Scripting

Format output in AWK command

hi Friends , I have a file as below s.txt 1~2~~4 2~6~~7 3~8~~9 t.txt 1~2~~4 2~5~8~7 3~8~~7 header for both files is common (2 Replies)
Discussion started by: i150371485
2 Replies

9. Shell Programming and Scripting

Format output using awk

Hello all , need help with this ... Input File DEV % POOL 0CB4 FBA 2211300 81792 4 IE RAID-5(3+1) R5_EFD100_1 - - 1805376 82 IF RAID-1 M2_FC300_1 - ... (4 Replies)
Discussion started by: greycells
4 Replies

10. Shell Programming and Scripting

Need to maintain in- and output format with awk

Hi All, I have a data file (myfile.txt) as below: - A H C - A HHH F - AAA HH I The importan point is that the width between the columns are not fixed and the column seperator is space. I wish to change the value of 4th column using awk only when $3 = HH. I can... (4 Replies)
Discussion started by: angshuman
4 Replies
Hash::Util(3pm) 					 Perl Programmers Reference Guide					   Hash::Util(3pm)

NAME
Hash::Util - A selection of general-utility hash subroutines SYNOPSIS
use Hash::Util qw(lock_keys unlock_keys lock_value unlock_value lock_hash unlock_hash); %hash = (foo => 42, bar => 23); lock_keys(%hash); lock_keys(%hash, @keyset); unlock_keys(%hash); lock_value (%hash, 'foo'); unlock_value(%hash, 'foo'); lock_hash (%hash); unlock_hash(%hash); DESCRIPTION
"Hash::Util" contains special functions for manipulating hashes that don't really warrant a keyword. By default "Hash::Util" does not export anything. Restricted hashes 5.8.0 introduces the ability to restrict a hash to a certain set of keys. No keys outside of this set can be added. It also introduces the ability to lock an individual key so it cannot be deleted and the value cannot be changed. This is intended to largely replace the deprecated pseudo-hashes. lock_keys unlock_keys lock_keys(%hash); lock_keys(%hash, @keys); Restricts the given %hash's set of keys to @keys. If @keys is not given it restricts it to its current keyset. No more keys can be added. delete() and exists() will still work, but will not alter the set of allowed keys. Note: the current implementation prevents the hash from being bless()ed while it is in a locked state. Any attempt to do so will raise an exception. Of course you can still bless() the hash before you call lock_keys() so this shouldn't be a problem. unlock_keys(%hash); Removes the restriction on the %hash's keyset. lock_value unlock_value lock_value (%hash, $key); unlock_value(%hash, $key); Locks and unlocks an individual key of a hash. The value of a locked key cannot be changed. %hash must have already been locked for this to have useful effect. lock_hash unlock_hash lock_hash(%hash); lock_hash() locks an entire hash, making all keys and values readonly. No value can be changed, no keys can be added or deleted. unlock_hash(%hash); unlock_hash() does the opposite of lock_hash(). All keys and values are made read/write. All values can be changed and keys can be added and deleted. AUTHOR
Michael G Schwern <schwern@pobox.com> on top of code by Nick Ing-Simmons and Jeffrey Friedl. SEE ALSO
Scalar::Util, List::Util, Hash::Util perl v5.8.0 2002-06-01 Hash::Util(3pm)
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy