07-31-2012
sum from ls -al |awk '{print $5}'
// AIX 5.3 & AIX 6.1
HTML Code:
ls -al |awk '{print $5}'
This gives each file's size in byte.
I need to get:
- the sum of all files in Giga bytes with loop.
- excluding the size of directories (ls -al returns the size of directories).
There are hundreds and thousands of files, so summing up with loop is needed.
Please advise.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
Hi all,
I need to sum values for fields in a delimited file as below:
2010-03-05|||
2010-03-05|||123
2010-03-05|467.621|369.532|
2010-03-06|||
2010-03-06||2|
2010-03-06|||444
2010-03-07|||
2010-03-07|||
2010-03-07|655.456|1019.301|
Code used is:
nawk -F "|" ' { sum +=... (7 Replies)
Discussion started by: Katabatic
7 Replies
3. Shell Programming and Scripting
Hi
i data looks like this:
student 1
Subject1 45 55
Subject2 44 55
Subject3 33 44
//
student 2
Subject1 45 55
Subject2 44 55
Subject3 33 44
i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies
4. Shell Programming and Scripting
Hi,
I am unable sum of each column in the loop usng awk command.
Awk is not allowing the parameters in the command.
i am facing the below error.
awk: 0602-562 Field $() is not correct.
Source file
abc.txt
100,200,300,400,500,600,700,800,900
101,201,301,401,501,601,701,801,901
... (1 Reply)
Discussion started by: number10
1 Replies
5. Shell Programming and Scripting
Coins.txt:
gold 1 1986 USA American Eagle
gold 1 1908 Austria-Hungary Franz Josef 100 Korona
silver 10 1981 USA ingot
gold 1 1984 Switzerland ingot
gold 1 1979 RSA Krugerrand
gold 0.5 1981 RSA Krugerrand
gold 0.1 1986 PRC Panda
silver 1 1986 USA Liberty dollar
gold 0.25 1986 USA Liberty... (2 Replies)
Discussion started by: Ramesh M
2 Replies
6. Shell Programming and Scripting
I have the input file in attached.
I want the output file :
Date , Time , Max_Bearer
11/01/2013 , 23:00 , 1447.894167
11/02/2013 , 00:00 , 1429.266667
11/03/2013 , 00:00 , 712.3175
11/04/2013 , 22:00 , 650.9533333
11/05/2013 , 23:00 , 665.9558333
11/06/2013 , 23:00 , 659.8616667... (2 Replies)
Discussion started by: justbow
2 Replies
7. Shell Programming and Scripting
Hi
I have attached txt file as input,
and i'm able to calculate sum of columns at the end but the format of sum is not coming up right.
awk -F"," '{for (i=4;i<=NF;i++) sum+=$i}{print}; END { sum="Total:"; for (i=1;i<=NF;i++) {printf sum ","} print "\n"}' input.txt
check the o/p file, at... (6 Replies)
Discussion started by: manas_ranjan
6 Replies
8. Shell Programming and Scripting
Hi,
I have an awk command that I am using, and part of it sums COL_9 however when I read the output it is not including decimal places;
awk '
BEGIN{FS=OFS=","}
NR==1{print;next}
{a+=$9
c = $12
d = $18
}
END{for(i in a) {split(i,b,";"); print $1, $2, $3, b, $5, $6, b, b, a, $10, $11,... (1 Reply)
Discussion started by: Ads89
1 Replies
9. Shell Programming and Scripting
This is my file
vol0 285GB
vol0.snapshot 15GB
vol11_root 0GB
vol12_root 47GB
vol12_root.snapshot 2GB
I need the output
vol0 285GB,vol0.snapshot 15GB,sum-300GB
vol11_root 0GB,nosnap,sum-0Gb
vol12_root 47GB,vol12_root.snapshot 2GB,49GB
I was trying to use paste -d, --. But... (9 Replies)
Discussion started by: ranjancom2000
9 Replies
LEARN ABOUT DEBIAN
html::elementglob
HTML::ElementGlob(3pm) User Contributed Perl Documentation HTML::ElementGlob(3pm)
NAME
HTML::ElementGlob - Perl extension for managing HTML::Element based objects as a single object.
SYNOPSIS
use HTML::ElementGlob;
$element_a = new HTML::Element 'font', color => 'red';
$element_b = new HTML::Element 'font', color => 'blue';
$element_a->push_content('red');
$element_b->push_content('blue');
$p = new HTML::Element 'p';
$p->push_content($element_a, ' and ', $element_b, ' boo hoo hoo');
# Tag type of the glob is not really relevant unless
# you plan on seeing the glob as_HTML()
$eglob = new HTML::ElementGlob 'p';
$eglob->glob_push_content($element_a, $element_b);
# Alter both elements at once
$eglob->attr(size => 5);
# They still belong to their original parent
print $p->as_HTML;
DESCRIPTION
HTML::ElementGlob is a managing object for multiple HTML::Element(3) style elements. The children of the glob element retain their
original parental elements and have no knowledge of the glob that manipulates them. All methods that do not start with 'glob_' will be
passed, sequentially, to all elements contained within the glob element. Methods starting with 'glob_' will operate on the glob itself,
rather than being passed to its foster children.
For example, $eglob->attr(size => 3) will invoke attr(size => 3) on all children contained by $eglob. $eglob->glob_attr(size => 3), on the
other hand, will set the attr attribute on the glob itself.
The tag type passed to HTML::Element::Glob is largely irrrelevant as far as how methods are passed to children. However, if you choose to
invoke $eglob->as_HTML(), you might want to pick a tag that would sensibly contain the globbed children for debugging or display purposes.
The 'glob_*' methods that operate on the glob itself are limited to those available in an HTML::Element(3). All other methods get passed
blindly to the globbed children, which can be enhanced elements with arbitrary methods, such as HTML::ElementSuper(3).
Element globs can contain other element globs. In such cases, the plain methods will cascade down to the leaf children. 'glob_*' methods,
of course, will not be propogated to children globs. You will have to rely on glob_content() to access those glob children and access
their 'glob_*' methods directly.
REQUIRES
HTML::ElementSuper(3)
AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com>
COPYRIGHT
Copyright (c) 1998-2010 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
SEE ALSO
HTML::Element(3), HTML::ElementSuper, HTML::ElementRaw, HTML::Element::Table(3), perl(1).
perl v5.10.1 2010-06-09 HTML::ElementGlob(3pm)