sed or grep
Following two commands do the same thing:
Code:
sed -ne '/^dog$/p' animallist.txt Code:
grep '^dog$' animallist.txt |
If you're just trying to find text, not replace it, grep seems the more natural tool to me.
I guess I can't confirm that it's any faster/slower, though. |
Quote:
if there is no dog in animallist then grep will return exit status 1, while sed - 0. If command used in the script exit status may be important. About CPU and memory - no idea. Unless file is very big I don't think you'll fell any practical difference |
Quote:
|
Quote:
|
Quote:
Code:
$ time your_sed_command Code:
$ time your_grep_command Code:
# time updatedb |
There's also the GNU version of time (\time) for more detail eg
Code:
cd / |
Quote:
|
All times are GMT -5. The time now is 08:40 PM. |