python vs awk for simple sysamin tasks

Matthew Thorley ruach at chpc.utah.edu
Thu Jun 3 02:18:26 EDT 2004


My friend sent me an email asking this:

 > I'm attemtping to decide which scripting language I should master and 
 > was wondering if it's possible to do
 > these unixy awkish commands  in python:
 >
 > How to find the amount of disk space a user is taking up:
 >
 > find / -user rprice -fstype nfs ! -name /dev/\* -ls | awk '{sum+=$7};\
 > {print "User rprice total disk use = " sum}'
 >
 > How to find the average size of a file for a user:
 >
 > find / -user rprice -fstype nfs ! -name /dev/\* -ls | awk '{sum+=$7};\
 > {print "The ave size of file for rprice is = " sum/NR}'

I wasn't able to give him an afirmative answer because I've never used 
python for things like this. I just spent the last while looking on 
google and haven't found an answer yet. I was hoping some one out there 
might have some thoughts ?

thanks much
-matthew



More information about the Python-list mailing list