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
|
|