Link to home
Create AccountLog in
Avatar of aggunia
agguniaFlag for United States of America

asked on

How do I find media files on a Unix web server?

I need help with a script, either shell or Perl, to search for media files on a web server (AIX).  Here's what I need it to do:

1)  finds a list of files based on a list of extensions (i.e. .mp3, .wav, .wmv, etc.)
2)  Sorts the files by type, and then sums the file types by counting them, giving the total size for that type, and then the average size of the files
3)  Gives a total count, total size, and average size for all files.

Thanks for any help someone can provide.  
Avatar of amit_g
amit_g
Flag of United States of America image

ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); Count[fileExt]++; Size[fileExt] += $5;} END { printf("%20s%10s%10s%10s\n", "Ext", "Count", "Size", "Avg"); for (fileExt in Count) { printf("%20s%10d%10d%10d\n", fileExt, Count[fileExt], Size[fileExt], Size[fileExt] / Count[fileExt]); SizeTotal += Size[fileExt]; CountTotal += Count[fileExt];} printf("%20s%10d%10d%10d\n", "Total", CountTotal, SizeTotal, SizeTotal / CountTotal);}'
Avatar of aggunia

ASKER

Thanks!  I get this error though when I run it:

?*+ not preceded by valid expression.

                 Ext     Count      Size       Avg
awk: 0602-566 Cannot divide by zero.
 The source line number is 1.
Break up the command line and run individual command(s) one by one. Post the results/error you get.

ls -lR
ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'
ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " "
ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " " | awk '{print}';
ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';
Avatar of aggunia

ASKER

Here you go:

#ls -lR | more
total 120
drwxr-sr-x   8 webcon   webmin          512 Jun 26 11:04 cgi-bin
drwxr-sr-x  11 webcon   webmin          512 Jul 07 07:25 fdlwebs
drwxrwxr-x   2 webcon   webmin          512 Jan 30 2006  lost+found
drwxr-sr-x  16 webcon   webmin          512 Sep 05 13:39 public
drwxr-sr-x   6 webcon   webmin          512 Jun 22 16:02 secure
...

#ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'
?*+ not preceded by valid expression.

 #ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " "
?*+ not preceded by valid expression.

 #ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " " | awk '{print}';
?*+ not preceded by valid expression.

ls -lR | egrep '^(*\.mp3)|(*\.wav)|(*\.wmv)$'| tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';

?*+ not preceded by valid expression.

What do you get from this

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$'
Which ' are you using? The one under the quotes or the one under the ~?
Avatar of aggunia

ASKER

This works:

#ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$'
-rw-r--r--   1 root     webmin            0 Sep 18 11:05 tony.mp3
-rw-r--r--   1 root     webmin            0 Sep 18 11:05 tony.wav
-rw-r--r--   1 root     webmin            0 Sep 18 11:05 tony.wmv

Sorry for the late reply...been out of town.
Change the original command to

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$' | tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); Count[fileExt]++; Size[fileExt] += $5;} END { printf("%20s%10s%10s%10s\n", "Ext", "Count", "Size", "Avg"); for (fileExt in Count) { printf("%20s%10d%10d%10d\n", fileExt, Count[fileExt], Size[fileExt], Size[fileExt] / Count[fileExt]); SizeTotal += Size[fileExt]; CountTotal += Count[fileExt];} printf("%20s%10d%10d%10d\n", "Total", CountTotal, SizeTotal, SizeTotal / CountTotal);}'

If this gives problem, run it one command at a time i.e. start with the last one working

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$'
then add next command and so on. Post results of each or error that you get
ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$' | tr -s " "
ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$' | tr -s " " | awk '{print}';
ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$' | tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';
Avatar of aggunia

ASKER

OK...this is working,but not getting the size and avg:

#d%10d%10d\n", "Total", CountTotal, SizeTotal, SizeTotal / CountTotal);}'                        <
                 Ext     Count      Size       Avg
                 wmv         1         0         0
                 mp3         1         0         0
                 wav         1         0         0
               Total         3         0         0

Close.....thanks!
Do all these files have zero size?
Avatar of aggunia

ASKER

Yep...they were.  Just put some content in them and got the following:

#ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$' | tr -s " " | awk '{fileName = $9; fileExt = $9>
                 Ext     Count      Size       Avg
                 wmv         1       224       224
                 mp3         1       425       425
                 wav         1       265       265
               Total         3       914       304


Really nice...thanks, this will work!
Avatar of aggunia

ASKER

OK...ran in to a problem here.  I added .swf to the string to find files with this extension, and received unexpected results.  Here's my ouput:

                 Ext     Count      Size       Avg
             hlp_mem         1     48021     48021
                 swf      1642 131865097     80307
   mem_update_online         1     46539     46539
            Intro_mc         1    704346    704346
            intro_il         1     21017     21017
                 mp3         1         0         0
                 wav         1         0         0
           pub_pfr_3         1     36750     36750
               Total      1649 132721770     80486

The other types like "mem_update_online" are really .swf files, but it appears the common thing about them is that there are multiple files in the subdirectories.  What would I add in the string to correct this?  Thanks.
Those are files or directories? and what do you expect the result to look like?
Avatar of aggunia

ASKER

They are files with the .swf extension.  So, they should be in the swf count, not listed as their own type.  Thanks!
I did not understand. Could you please elaborate with output of

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)|(.*\.swf)$'

posted here. Don't post all 1642+ lines, just post a sample. Take out most of the repeating files with .swf with just 2 or 3 of those.
Avatar of aggunia

ASKER

Here you go...the 'hlp_mem' is there twice.  Thanks.

-rwxr-xr-x   1 root     webmin        10318 Jun 23 14:04 il_emp_header_menu.swf
-rwxr-xr-x   1 root     webmin         6338 Jun 23 14:04 il_emp_header_search.swf
-rwxr-xr-x   1 root     webmin        13655 Jun 23 14:04 il_mem_header_menu.swf
-rwxr-xr-x   1 root     webmin         9754 Jun 23 14:04 il_pub_provider_search.swf
-rwxr-xr-x   1 root     webmin         4638 Jun 23 14:04 index.swf
-rwxr-xr-x   1 root     webmin        14758 Jun 23 14:04 intro_nm.swf
-rwxr-xr-x   1 root     webmin           30 Jun 23 14:04 load_intro.swf
-rwxr-xr-x   1 root     webmin        27894 Jun 23 14:04 nav_emp.swf
-rwxr-xr-x   1 root     webmin         7245 Jun 23 14:04 acc_id.swf
-rwxr-xr-x   1 root     webmin         9902 Jun 23 14:04 acc_sum.swf
-rwxr-xr-x   1 root     webmin        12055 Jun 23 14:04 bill_cha.swf
-rwxr-xr-x   1 root     webmin        10338 Jun 23 14:04 bill_sum.swf
-rwxr-xr-x   1 root     webmin         8184 Jun 23 14:04 del_add.swf
-rwxr-xr-x   1 root     webmin        10100 Jun 23 14:04 enr_pen.swf
-rwxr-xr-x   1 root     webmin        12236 Jun 23 14:04 enr_per.swf
-rwxr-xr-x   1 root     webmin        12551 Jun 23 14:04 enr_rev.swf
-rwxr-xr-x   1 root     webmin        18265 Jun 23 14:04 enr_wel.swf
-rwxr-xr-x   1 root     webmin        10526 Jun 23 14:04 onl_emp.swf
-rwxr-xr-x   1 root     webmin        11198 Jun 23 14:04 onl_sum.swf
-rwxr-xr-x   1 root     webmin        15260 Jun 23 14:04 pro_sum.swf
-rwxr-xr-x   1 root     webmin        31462 Jun 23 14:04 hlp_mem.swf
-rwxr-xr-x   1 root     webmin        13655 Jun 23 14:04 il_mem_header_menu.swf
-rwxr-xr-x   1 root     webmin         4700 Jun 23 14:04 index.swf
-rwxr-xr-x   1 root     webmin        14737 Jun 23 14:04 intro_nm.swf
-rwxr-xr-x   1 root     webmin           30 Jun 23 14:04 load_intro.swf
-rwxr-xr-x   1 root     webmin        17645 Jun 23 14:04 mem_ben.swf
-rwxr-xr-x   1 root     webmin        33184 Jun 23 14:04 mem_claim_eob.swf
-rwxr-xr-x   1 root     webmin        14200 Jun 23 14:04 mem_claim_summ.swf
-rwxr-xr-x   1 root     webmin        13005 Jun 23 14:04 mem_contact.swf
-rwxr-xr-x   1 root     webmin        10290 Jun 23 14:04 mem_exit.swf
-rwxr-xr-x   1 root     webmin         3743 Jun 23 14:04 mem_footer.swf
-rwxr-xr-x   1 root     webmin        13643 Jun 23 14:04 mem_hca.swf
-rwxr-xr-x   1 root     webmin        13628 Jun 23 14:04 mem_header.swf
-rwxr-xr-x   1 root     webmin        15751 Jun 23 14:04 mem_hmo.swf
-rwxr-xr-x   1 root     webmin        14249 Jun 23 14:04 mem_home.swf
-rwxr-xr-x   1 root     webmin        28516 Jun 23 14:04 mem_hs_adv.swf
-rwxr-xr-x   1 root     webmin        14331 Jun 23 14:04 mem_hs_pg1.swf
-rwxr-xr-x   1 root     webmin        19527 Jun 23 14:04 mem_hs_pg2.swf
-rwxr-xr-x   1 root     webmin        17226 Jun 23 14:04 mem_hs_pg3.swf
-rwxr-xr-x   1 root     webmin        24685 Jun 23 14:04 mem_hs_pg4.swf
-rwxr-xr-x   1 root     webmin        26616 Jun 23 14:04 mem_hs_pg5.swf
-rwxr-xr-x   1 root     webmin        20818 Jun 23 14:04 mem_hs_summ.swf
-rwxr-xr-x   1 root     webmin        43034 Jun 23 14:04 mem_hw_home.swf
/
-rwxr-xr-x   1 root     webmin        14833 Jun 23 14:05 help_7.swf
-rwxr-xr-x   1 root     webmin        10487 Jun 23 14:05 help_8.swf
-rwxr-xr-x   1 root     webmin         6138 Jun 23 14:05 help_9.swf
-rwxr-xr-x   1 root     webmin        31934 Jun 23 14:05 onl_emp_caption.swf
-rwxr-xr-x   1 root     webmin        24162 Jun 23 14:05 onl_sum_caption.swf
-rwxr-xr-x   1 root     webmin        46273 Jun 23 14:05 pro_sum_caption.swf
-rwxr-xr-x   1 root     webmin        23410 Jun 23 14:05 pro_sum_caption2.swf
-rwxr-xr-x   1 root     webmin        30125 Jun 23 14:05 pub_det_1.swf
-rwxr-xr-x   1 root     webmin        33591 Jun 23 14:05 pub_emp_caption1.swf
-rwxr-xr-x   1 root     webmin        11050 Jun 23 14:05 pub_emp_caption2.swf
-rwxr-xr-x   1 root     webmin        38684 Jun 23 14:05 pub_emp_caption3.swf
-rwxr-xr-x   1 root     webmin        59041 Jun 23 14:05 pub_emp_caption4.swf
-rwxr-xr-x   1 root     webmin        50672 Jun 23 14:05 pub_form.swf
-rwxr-xr-x   1 root     webmin        21672 Jun 23 14:05 pub_pfr_2.swf
-rwxr-xr-x   1 root     webmin        37525 Jun 23 14:05 pub_pfr_3.swf
-rwxr-xr-x   1 root     webmin        44912 Jun 23 14:05 pub_pfs.swf
-rwxr-xr-x   1 root     webmin        22134 Jun 23 14:05 pub_phar.swf
-rwxr-xr-x   1 root     webmin        47488 Jun 23 14:05 pub_pre.swf
-rwxr-xr-x   1 root     webmin        20410 Jun 23 14:05 rep_sea_caption.swf
-rwxr-xr-x   1 root     webmin        20724 Jun 23 14:05 rep_sea_caption2.swf
-rwxr-xr-x   1 root     webmin        31481 Jun 23 14:05 hlp_mem.swf
-rwxr-xr-x   1 root     webmin        13655 Jun 23 14:05 il_mem_header_menu.swf
-rwxr-xr-x   1 root     webmin         4684 Jun 23 14:05 index.swf
-rwxr-xr-x   1 root     webmin        17645 Jun 23 14:05 mem_ben.swf
-rwxr-xr-x   1 root     webmin        33184 Jun 23 14:05 mem_claim_eob.swf
For this output the script works fine. Somthing else is causing it. What do you get from these?

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | egrep 'hlp_mem|mem_update_online|Intro_mc|intro_il|pub_pfr_3'
ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';
Avatar of aggunia

ASKER

Here you go:

#(.*\.swf)$' | egrep 'hlp_mem|mem_update_online|Intro_mc|intro_il|pub_pfr_3'                     <
ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';

-rwxrwxr-x   1 webcon   webmin       704346 Sep 28 2004  Intro_mc full.swf
-rwxrwxr-x   1 webcon   webmin       282615 Sep 30 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin       283048 Oct 21 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin       112696 Oct 01 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin        19444 Aug 23 2004  intro_il.swf
-rwxrwxr-x   1 webcon   webmin        28272 Apr 21 2004  hlp_mem.swf
-rwxrwxr-x   1 webcon   webmin        21017 Apr 21 2004  intro_il web.swf
-rwxrwxr-x   1 webcon   webmin        21017 Apr 21 2004  intro_il.swf
-rwxrwxr-x   1 webcon   webmin        13488 Apr 21 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin        46539 Apr 21 2004  mem_update_online x.swf
-rwxrwxr-x   1 webcon   webmin        18716 Apr 21 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin        19777 Apr 21 2004  mem_update_online2.swf
-rwxrwxr-x   1 webcon   webmin        36750 Apr 21 2004  pub_pfr_3 xx.swf
-rwxrwxr-x   1 webcon   webmin        37867 Apr 21 2004  pub_pfr_3.swf
-rwxr-xr-x   1 root     webmin        31462 Jun 23 14:04 hlp_mem.swf
-rwxr-xr-x   1 root     webmin        11663 Jun 23 14:04 mem_update_online.swf
-rwxr-xr-x   1 root     webmin        22503 Jun 23 14:04 mem_update_online.swf
-rwxr-xr-x   1 root     webmin        37525 Jun 23 14:05 pub_pfr_3.swf
-rwxr-xr-x   1 root     webmin        31481 Jun 23 14:05 hlp_mem.swf
-rwxr-xr-x   1 root     webmin        11663 Jun 23 14:05 mem_update_online.swf
-rwxr-xr-x   1 root     webmin        22503 Jun 23 14:05 mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin       283238 Oct 05 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin       112836 Oct 05 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin        48021 Apr 13 2004  hlp_mem yyy.swf
-rwxrwxr-x   1 webcon   webmin        35924 Apr 13 2004  hlp_mem.swf
-rwxrwxr-x   1 webcon   webmin        13342 Apr 13 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin         9526 Apr 13 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin         9654 Apr 13 2004  mem_update_online2.swf
-rwxrwxr-x   1 webcon   webmin        36750 Apr 13 2004  pub_pfr_3.swf
-rwxrwxr-x   1 webcon   webmin        17424 Jul 26 2004  Intro_mc.swf
#
This also looks ok. What was the output of

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | tr -s " " | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';

Avatar of aggunia

ASKER

Output looks like this:

mp3
wav
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
Intro_mc
swf
swf
Oh you have blank space in filenames. Try

ls -blR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | tr -s " " | sed 's/\\./_/g' | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';

and run it on the same set. Now fileext like Intro_mc should be gone. If so your new command would be

ls -blR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.swf)|(.*\.wmv)$' | tr -s " " | sed 's/\\./_/g' | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); Count[fileExt]++; Size[fileExt] += $5;} END { printf("%20s%10s%10s%10s\n", "Ext", "Count", "Size", "Avg"); for (fileExt in Count) { printf("%20s%10d%10d%10d\n", fileExt, Count[fileExt], Size[fileExt], Size[fileExt] / Count[fileExt]); SizeTotal += Size[fileExt]; CountTotal += Count[fileExt];} printf("%20s%10d%10d%10d\n", "Total", CountTotal, SizeTotal, SizeTotal / CountTotal);}'
Avatar of aggunia

ASKER

OK...ran the first line and still see that file:

swf
swf
swf
Intro_mc
swf
swf
swf
swf


Running the entire string produces as follows:
                 Ext     Count      Size       Avg
             hlp_mem         1     48021     48021
                 swf      1642 131865097     80307
   mem_update_online         1     46539     46539
            Intro_mc         1    704346    704346
            intro_il         1     21017     21017
                 mno         3       366       122
                 mp3         1         0         0
             swf-BAK         2    430400    215200
                 wav         1         0         0
           pub_pfr_3         1     36750     36750
               Total      1654 133152536     80503

Did you add -b option in ls? Post the output of

ls -blR Intro*
Avatar of aggunia

ASKER

I get nothing when I do that:

#ls -blR Intro*
ls: 0653-341 The file Intro* does not exist.

I did use the -b option in the prior post.  Thanks.
What is the output of commands

ls -blR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | egrep 'hlp_mem|mem_update_online|Intro_mc|intro_il|pub_pfr_3'

and

ls -lbR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | tr -s " " | sed 's/\\./_/g' | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';
Avatar of aggunia

ASKER

Here you go:
ls -blR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | egrep 'hlp_mem|mem_update_online|Intro_mc|intro_il|pub_pfr_3'
-rwxrwxr-x   1 webcon   webmin       704346 Sep 28 2004  Intro_mc full.swf
-rwxrwxr-x   1 webcon   webmin       282615 Sep 30 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin       283048 Oct 21 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin       112696 Oct 01 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin        19444 Aug 23 2004  intro_il.swf
-rwxrwxr-x   1 webcon   webmin        28272 Apr 21 2004  hlp_mem.swf
-rwxrwxr-x   1 webcon   webmin        21017 Apr 21 2004  intro_il web.swf
-rwxrwxr-x   1 webcon   webmin        21017 Apr 21 2004  intro_il.swf
-rwxrwxr-x   1 webcon   webmin        13488 Apr 21 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin        46539 Apr 21 2004  mem_update_online x.swf
-rwxrwxr-x   1 webcon   webmin        18716 Apr 21 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin        19777 Apr 21 2004  mem_update_online2.swf
-rwxrwxr-x   1 webcon   webmin        36750 Apr 21 2004  pub_pfr_3 xx.swf
-rwxrwxr-x   1 webcon   webmin        37867 Apr 21 2004  pub_pfr_3.swf
-rwxr-xr-x   1 root     webmin        31462 Jun 23 14:04 hlp_mem.swf
-rwxr-xr-x   1 root     webmin        11663 Jun 23 14:04 mem_update_online.swf
-rwxr-xr-x   1 root     webmin        22503 Jun 23 14:04 mem_update_online.swf
-rwxr-xr-x   1 root     webmin        37525 Jun 23 14:05 pub_pfr_3.swf
-rwxr-xr-x   1 root     webmin        31481 Jun 23 14:05 hlp_mem.swf
-rwxr-xr-x   1 root     webmin        11663 Jun 23 14:05 mem_update_online.swf
-rwxr-xr-x   1 root     webmin        22503 Jun 23 14:05 mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin       283238 Oct 05 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin       112836 Oct 05 2004  Intro_mc.swf
-rwxrwxr-x   1 webcon   webmin        48021 Apr 13 2004  hlp_mem yyy.swf
-rwxrwxr-x   1 webcon   webmin        35924 Apr 13 2004  hlp_mem.swf
-rwxrwxr-x   1 webcon   webmin        13342 Apr 13 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin         9526 Apr 13 2004  mem_update_online.swf
-rwxrwxr-x   1 webcon   webmin         9654 Apr 13 2004  mem_update_online2.swf
-rwxrwxr-x   1 webcon   webmin        36750 Apr 13 2004  pub_pfr_3.swf
-rwxrwxr-x   1 webcon   webmin        17424 Jul 26 2004  Intro_mc.swf


ls -lbR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.wmv)$|(.*\.swf)$' | tr -s " " | sed 's/\\./_/g' | awk '{fileName = $9; fileExt = $9; sub(/.*\./, "", fileExt); print fileExt}';
swf
swf
swf
swf
swf
swf
swf
Intro_mc
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
swf
intro_il
swf
swf
swf
mem_update_online
swf
swf
swf
swf
swf
swf
swf
swf
swf
pub_pfr_3
swf
swf
swf
swf
hlp_mem
swf
swf
You -b isn't doing what I expected so lets try some other method. Try

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.swf)|(.*\.wmv)$' | tr -s " " | sed 's/\\./_/g' | awk '{len = split($0, arr); fileName = ""; for (i = 9 ; i <= len ; i++) fileName = fileName arr[i]; fileExt = fileName; sub(/.*\./, "", fileExt); Count[fileExt]++; Size[fileExt] += $5;} END { printf("%20s%10s%10s%10s\n", "Ext", "Count", "Size", "Avg"); for (fileExt in Count) { printf("%20s%10d%10d%10d\n", fileExt, Count[fileExt], Size[fileExt], Size[fileExt] / Count[fileExt]); SizeTotal += Size[fileExt]; CountTotal += Count[fileExt];} printf("%20s%10d%10d%10d\n", "Total", CountTotal, SizeTotal, SizeTotal / CountTotal);}'

If that doesn't work proprly, post the output of

ls -lR | egrep '^(.*\.mp3)|(.*\.wav)|(.*\.swf)|(.*\.wmv)$' | tr -s " " | sed 's/\\./_/g' | awk '{len = split($0, arr); fileName = ""; for (i = 9 ; i <= len ; i++) fileName = fileName arr[i]; fileExt = $9; sub(/.*\./, "", fileExt); print fileName "##" fileExt}';
Avatar of aggunia

ASKER

OK...didn't work properly:

                 Ext     Count      Size       Avg
                 swf      1647 132721770     80583
                 mno         3       366       122
                 mp3         1         0         0
             swf-BAK         2    430400    215200
                 wav         1         0         0
               Total      1654 133152536     80503


So here's that output you requested:

bae_onlinebp_il.swf##swf
bae_onlinebp_il_1012.swf##swf
bae_onlinebp_tx.swf##swf
bae_onlinebp_tx_1012.swf##swf
blue_edge.swf##swf
blue_edge_il.swf##swf
blue_edge_tx.swf##swf
sa_blueaccess_mc_v4.swf##swf
sfx.swf##swf
kids_header.swf##swf
bamilpinreq1.swf##swf
BAM_IL05.swf##swf
Intro_mcfull.swf##Intro_mc
Intro_mc.swf##swf
index.swf##swf
main.swf##swf
Example_mc.swf##swf
Individual_2_mc.swf##swf
rep_sea_caption.swf##swf
rep_sea_caption2.swf##swf
hlp_mem.swf##swf
il_mem_header_menu.swf##swf
il_pub_provider_search.swf##swf
index.swf##swf
intro_ilweb.swf##intro_il
intro_il.swf##swf
mem_ben.swf##swf
mem_claim_eob.swf##swf
mem_claim_summ.swf##swf
mem_contact.swf##swf
mem_exit.swf##swf
mem_footer.swf##swf
mem_hca.swf##swf


ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of aggunia

ASKER

It's working fine for what I need at this point.  Thanks for your help with this, and sorry for the late response.