对于简单的sysamin任务,python vs awk [英] python vs awk for simple sysamin tasks

查看:65
本文介绍了对于简单的sysamin任务,python vs awk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友给我发了一封电子邮件询问:

我正在决定我应该掌握哪种脚本语言,并且想知道它是否可能在python中执行这些unixy awkish命令:

如何找到用户占用的磁盘空间量:

find / -user rprice -fstype nfs! -name / dev / \ * -ls | awk''{sum + = $ 7}; \
{print"用户rprice总磁盘使用="总结}''

如何为用户找到文件的平均大小:

查找/ -user rprice -fstype nfs! -name / dev / \ * -ls | awk''{sum + = $ 7}; \
{print" rprice文件的大小是=" sum / NR}''




我无法给出肯定答案,因为我从未使用过

python对于这样的事情。我只是花了最后一次看着

google并且还没有找到答案。我希望有一个人在那里

可能会有一些想法吗?


非常感谢

-matthew

解决方案

7}; \
{print" User rprice total disk use ="总结}''

如何为用户找到文件的平均大小:

查找/ -user rprice -fstype nfs! -name / dev / \ * -ls | awk''{sum + =


7}; \
{print" rprice的文件大小是=" sum / NR}''




我无法给出肯定答案,因为我从未使用过

python对于这样的事情。我只是花了最后一次看着

google并且还没有找到答案。我希望有一个人在那里

可能会有一些想法吗?


非常感谢

-matthew


2004-06-03,Matthew Thorley< ru *** @ chpc.utah.edu>写道:

我无法给他一个肯定的答案,因为我从来没有使用过这样的事情。我只是花了最后一次看谷歌并没有找到答案。我希望有一个人可能会有一些想法吗?




定义最终结果比塞满壳更好更好

我们必须破译的脚本。但是,对我来说,这将是一个简单的os.path.walk()问题,调用一个合适的函数,

根据需要进行计算。


-

Steve C. Lamb |我是你的牧师,我是你的缩水,我是你的

PGP钥匙:8B6E99C5 |与灵魂交换机的主要连接。

------------------------------- + - -------------------------------------------


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

解决方案

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


On 2004-06-03, Matthew Thorley <ru***@chpc.utah.edu> wrote:

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 ?



What would be better is defining the end result than cramming out shell
script that we''ve got to decipher. But, with that said to me it would be a
simple matter of os.path.walk() with a call to an appropriate function which
does the calculations as needed.

--
Steve C. Lamb | I''m your priest, I''m your shrink, I''m your
PGP Key: 8B6E99C5 | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------


这篇关于对于简单的sysamin任务,python vs awk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆