The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sort by size, then list file in each directory ChatPerdu UNIX for Dummies Questions & Answers 3 07-01-2009 06:10 PM
How to list a file size, but not its name? ordano UNIX for Dummies Questions & Answers 2 02-12-2009 02:00 AM
command to list file size rgordon HP-UX 3 12-05-2007 05:43 AM
List File size komputersman UNIX for Dummies Questions & Answers 10 06-13-2007 05:39 PM
list file within selected of day happyv Shell Programming and Scripting 1 11-15-2006 04:47 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2009
mail2sant mail2sant is offline
Registered User
  
 

Join Date: Apr 2008
Location: bangalore
Posts: 71
want to add the size of the selected list of file

i have a files in the dir as below.

ls -lR ./.snapshot

5649600512 ./.snapshot/backup/data20080707
6006923264 ./.snapshot/backup/data20080708
5321129984 ./.snapshot/backup/data20080709
6686597120 ./.snapshot/backup/data20080710
7312855040 ./.snapshot/backup/data20080711
6115131392 ./.snapshot/backup/data20080714
7423959040 ./.snapshot/backup/data20080715
5940617216 ./.snapshot/backup/data20080716
6156181504 ./.snapshot/backup/data
4912037888 ./.snapshot/backup/data20080718
4528926720 ./.snapshot/backup/data20080721


i want to add the first column ( unsing awk or anything )and want to see the total number of bytes for that

ls -lR ./.snapshot
  #2 (permalink)  
Old 09-28-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,449
To keep the forums high quality for all users, please take the time to format your posts correctly.
  1. Use Code Tags when you post any code or data samples so others can easily read your code.
    You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)
  2. Avoid adding color or different fonts and font size to your posts.
    Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
  3. Be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply With Quote


Code:
ls -lR ./.snapshot | awk '{t+=$1}1END{print t}'

  #3 (permalink)  
Old 09-28-2009
mail2sant mail2sant is offline
Registered User
  
 

Join Date: Apr 2008
Location: bangalore
Posts: 71
sorry i wrongly posted..
it is like

du -b ./.snapshot

5649600512 ./.snapshot/backup/data20080707
6006923264 ./.snapshot/backup/data20080708
5321129984 ./.snapshot/backup/data20080709
6686597120 ./.snapshot/backup/data20080710
7312855040 ./.snapshot/backup/data20080711
6115131392 ./.snapshot/backup/data20080714
7423959040 ./.snapshot/backup/data20080715
5940617216 ./.snapshot/backup/data20080716
6156181504 ./.snapshot/backup/data
4912037888 ./.snapshot/backup/data20080718
4528926720 ./.snapshot/backup/data20080721


i want to add the column one which is size
i want result like 5649600512 + 6006923264 ....etc
in the result
du -b ./.snapshot | awk '{print $1}' | ( here i want to add the whole column of data )
  #4 (permalink)  
Old 09-28-2009
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,449
Quote:
Originally Posted by mail2sant View Post
sorry i wrongly posted..
Again

Please read the Forum Rules & Guidelines, edit your post and add [code] tags

Next read the replies very carefully.


Code:
# du -b ./.snapshot | awk '{t+=$1}1END{print t}' f1
5649600512 ./.snapshot/backup/data20080707
6006923264 ./.snapshot/backup/data20080708
5321129984 ./.snapshot/backup/data20080709
6686597120 ./.snapshot/backup/data20080710
7312855040 ./.snapshot/backup/data20080711
6115131392 ./.snapshot/backup/data20080714
7423959040 ./.snapshot/backup/data20080715
5940617216 ./.snapshot/backup/data20080716
6156181504 ./.snapshot/backup/data
4912037888 ./.snapshot/backup/data20080718
4528926720 ./.snapshot/backup/data20080721
66053959680


Last edited by danmero; 09-28-2009 at 03:31 PM.. Reason: Fix typo, thanks c
  #5 (permalink)  
Old 09-28-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
s/reply's/replies/
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0