由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - UNIX Tip: the bad and the good
相关主题
How to find a file in the deep children directory?shell programming problems
ls in Unix (Sun) How do i get a list of all computers?
questionreplace a string in all files under a directory?
[转载] grep questionRe: 如何用grep查找子目录下的文件?--stop!
请问如何结束一个qlogin sessionRe: 如何用grep查找子目录下的文件?
面试中的unix, linux的几个问题,不知道自己答对了没有。sed? awk? or mak a program?
如何把一个目录下的文件名全部改成小写?how to grep a string in all sub-dirs?
[转载] How to list the files with specific permission?how to escape both ' and " from tcsh?
相关话题的讨论汇总
话题: grep话题: bad话题: somefile话题: better话题: unix
进入Unix版参与讨论
1 (共1页)
w*****n
发帖数: 94
1
THE BAD AND THE GOOD
I cringe anytime I see someone code inefficiently. Here are
three of the most common mistakes, followed by a better way to
do the same thing.
Bad: cat somefile | grep something
Better: grep something somefile
Why: You're running one program (grep) instead of two (cat
and grep).
Bad: ps -ef | grep something | grep -v grep
Better: ps -ef | grep [s]omething
Why: You抮e running two commands (grep) instead of three (ps
and two greps).
Bad: cat /dev/null > somefile
c*****t
发帖数: 1879
2
The later two tips work for /bin/sh (or bash) only.

【在 w*****n 的大作中提到】
: THE BAD AND THE GOOD
: I cringe anytime I see someone code inefficiently. Here are
: three of the most common mistakes, followed by a better way to
: do the same thing.
: Bad: cat somefile | grep something
: Better: grep something somefile
: Why: You're running one program (grep) instead of two (cat
: and grep).
: Bad: ps -ef | grep something | grep -v grep
: Better: ps -ef | grep [s]omething

1 (共1页)
进入Unix版参与讨论
相关主题
how to escape both ' and " from tcsh?请问如何结束一个qlogin session
where is the pre-build version of cxterm-solaris面试中的unix, linux的几个问题,不知道自己答对了没有。
Where's emacs' private dictionary?如何把一个目录下的文件名全部改成小写?
如何删除一组文件或给一组文件更名?[转载] How to list the files with specific permission?
How to find a file in the deep children directory?shell programming problems
ls in Unix (Sun) How do i get a list of all computers?
questionreplace a string in all files under a directory?
[转载] grep questionRe: 如何用grep查找子目录下的文件?--stop!
相关话题的讨论汇总
话题: grep话题: bad话题: somefile话题: better话题: unix