Sum of Files Sizes starting with a letter...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sum of Files Sizes starting with a letter...
# 1  
Old 07-25-2007
Sum of Files Sizes starting with a letter...

Can we find some of size of all files in a directry where file names start with an letter t*

the out put of ls -ls t* is

4 -rw-r--r-- 1 root system 61 Jul 03 10:56 t
4 -rw-r--r-- 1 root system 3146 Jul 19 11:11 t1
4 -rw-r--r-- 1 root system 3169 Jul 19 11:11 t2
4 -rw-r--r-- 1 root system 80 Jun 29 10:59 td
4 -rw-r--r-x 1 root system 206 Jul 13 07:25 te
16 -rw-r--r-x 1 root system 15670 Jul 19 15:19 tem
4 -rw-r--r-- 1 root system 13 Jul 25 10:42 temp
4 -rw-r--r-x 1 root system 694 Jul 18 12:12 temp.awk
0 -rw-r--r-- 1 root system 0 Jul 20 13:18 temp3365
4 -rw-r--r-- 1 root system 1313 Jul 18 11:07 tmp
400 -rw-r--r-- 1 root system 408968 Jul 12 13:11 tmp_File
4 -rw-r--r-x 1 root system 152 Jul 03 10:56 try
32 -rw-r--r-- 1 root system 30795 Jul 05 16:26 ts_lst


i want the sum of size of all the files..
# 2  
Old 07-25-2007
Code:
ls -ls t* | awk '{sum = sum + $6} END {print sum}'

# 3  
Old 07-25-2007
In bytes
Code:
$ ls -l | awk '$NF ~ /^t/ {c+=$5} END {print c}'

Cheers
ZB
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort alphabetically starting from specified letter

Hi. I'm trying to sort a list of items in a file alphabetically but starting from the letter 'X'. For instance if I had the following file; test.txt Z A T W Y B S X I would like the output to look like; X Y (8 Replies)
Discussion started by: mmab
8 Replies

2. Shell Programming and Scripting

Replace specific letter in a file by other letter

Good afternoon all, I want to ask how to change some letter in my file with other letter in spesific line eg. data.txt 1 1 1 0 0 0 0 for example i want to change the 4th line with character 1. How could I do it by SED or AWK. I have tried to run this code but actually did not... (3 Replies)
Discussion started by: weslyarfan
3 Replies

3. Shell Programming and Scripting

To merge different sizes txt files

Hi, I have to .txt files that look like "baseMean" "log2FoldChange" "lfcSE" "stat" "pvalue" "padj" "c104215_g2_i4" 202.057864855455 5.74047973414006 1.14052672909697 5.03318299141063 4.8240223910525e-07 0.00234905721174879 "c91544_g1_i1" 373.123487095726 5.62496675850204 1.15060014539303... (2 Replies)
Discussion started by: alisrpp
2 Replies

4. Shell Programming and Scripting

Listing Files and Sizes on FTP server

Need assistance in getting File size for the List of files using perl script . I have writtern 2 codes. One of them gives me the list of files and 2nd one give me the size for only 1 file. I dont know how to club both of them to get the list of files with its size . #!/usr/bin/perl -w... (11 Replies)
Discussion started by: ajayram_arya
11 Replies

5. Shell Programming and Scripting

Get all File names starting with letter P

Hi, I have lets say 10 files , I need to process them one by one. So I need a command to get one file name at a time to process it into a variable Example Files P1111.dat P3344.dat S344.dat ... v_file_name = 'p111.dat' .. I will rename it to something after processing ... (1 Reply)
Discussion started by: prassu
1 Replies

6. Shell Programming and Scripting

Comparing sizes in percentages of 2 files in bash

Hi guys, I hope you can enlight me with a script I'm doing for Solaris 10. Script goes like this: #!/usr/bin/bash fechahoy=`perl /export/home/info/John/fechamod.pl` fechayer=`perl /export/home/info/John/fecha.pl` echo $fechahoy echo $fechayer DAT1=`ssh ivt@blahblah ls -la... (1 Reply)
Discussion started by: sr00t
1 Replies

7. Homework & Coursework Questions

Grep for filetype starting with letter p

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Which files in /usr/bin whose names begin with “p” are python scripts? Store the numbered results in... (3 Replies)
Discussion started by: alindner
3 Replies

8. UNIX for Dummies Questions & Answers

sort lines in different files based on the starting letter

Hi ,, i have the below file... D 2342135 B 214236 C argjlksd V lskjrghaklsr C slkrgj B sdg4tsd E aslkgjlkasg i want to sort the lines into different files based on the starting letter of the line. so that i have different files for lines starting with a letter. thanks (1 Reply)
Discussion started by: jathin12
1 Replies

9. Shell Programming and Scripting

Search directories for files with zero sizes to delete

Hi, I am trying to write a script that will use ls on a directory and list the files one at a time and their size. If the size is 0 i want it to ask me if I want to delete it (yes or no). If I say yes, I want it to delete but it won't know what the file name is just from running from the script.... (2 Replies)
Discussion started by: akeenabawa
2 Replies

10. Shell Programming and Scripting

Join - files of different sizes

I am trying to join to files with dramatically different sizes (file 1: 1 column - 9000 rows, file 2: 13 cols, 26 million rows). I can't seem to get join to work. I have check to ensure that there are matches and have tried subsamples that work. The -a filenum flag lists all the rows, so join is... (4 Replies)
Discussion started by: annelie
4 Replies
Login or Register to Ask a Question