blob: e085cd0df916b3c7b996ef126c1cf3190073ea2c [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Guido van Rossumec758ea1991-06-04 20:36:54 +00002
3# suff
4#
5# show different suffixes amongst arguments
6
7import sys
8
9def main():
Tim Peters70c43782001-01-17 08:48:39 +000010 files = sys.argv[1:]
11 suffixes = {}
12 for file in files:
13 suff = getsuffix(file)
14 if not suffixes.has_key(suff):
15 suffixes[suff] = []
16 suffixes[suff].append(file)
17 keys = suffixes.keys()
18 keys.sort()
19 for suff in keys:
20 print `suff`, len(suffixes[suff])
Guido van Rossumec758ea1991-06-04 20:36:54 +000021
22def getsuffix(file):
Tim Peters70c43782001-01-17 08:48:39 +000023 suff = ''
24 for i in range(len(file)):
25 if file[i] == '.':
26 suff = file[i:]
27 return suff
Guido van Rossumec758ea1991-06-04 20:36:54 +000028
29main()