Ignore:
Timestamp:
Nov 18, 2004, 11:43:50 PM (20 years ago)
Author:
ole
Message:

Added examples of more advanced use of the "find" command

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/pytools/diskreport.py

    r24 r25  
    4040
    4141        try:
    42             x = float(fields[col])
     42            x = float(fields[4])
    4343        except:
    4444            pass
     45            print fields
    4546        else:
    4647            sizes.append(x)
    4748            A.append( fields )   
    4849       
    49 
    50     S = map(None, sizes, A)   
    51 
     50    # Schwartzian transform     
     51    S = [ (sizes[i], A[i]) for i in range(len(sizes)) ] #List comprehension   
    5252    S.sort()
    53 
    54     B = map(lambda x: x[1], A)
    55    
    56     print B
     53    B = [x[1] for x in S]
     54   
     55    print A, B
     56   
     57   
     58    return B
    5759   
    5860
     
    7577print 'DISKREPORT FOR DIRECTORY %s' %dir
    7678
    77 
    7879# Find the largest directories
    79 cmd = 'du -k %s | sort -nr > %s' %(dir, tempfile)
     80cmd = 'du -k "%s" | sort -nr > %s' %(dir, tempfile)
    8081#print cmd
    8182os.system(cmd)
     
    8586fid.close()
    8687
    87 txt = 'Top 50 largest directories'
     88txt = 'Top 50 largest directories on %s (stated in kilo bytes)' %dir
    8889os.system('echo "%s" > top50.txt' %txt)
    8990
     
    118119    l = line.strip()
    119120    oldfiles.append(l)
     121    #Use python os to get stats
     122    #Or use: find <path> -name <name> -type f -atime +30 -exec ls -all {} \;
     123    #find $1 -type f  -size +2048 -xdev -exec ls -s {} + | /bin/sort -nr
     124    #find / -xdev -size +1024 -exec ls -al {} \; | sort -r -k 5
     125   
     126    #GREAT ONE
     127    #find . -type f -size +10 -printf "%s %u %a %k %h%f \n" | sort -nr
     128   
     129    print os.stat(l)
    120130    cmd = 'ls -lua "%s" >> oldfiles.txt 2>/dev/null' %l
    121131    #print cmd
Note: See TracChangeset for help on using the changeset viewer.