Sometimes it's handy to redirect the output of a Linux/Unix command into an editor. One reason to do this might be to try to weed out unwanted search pattern matches when running grep. Fortunately the Linux (and before that Unix) developers have anticipated this need. Editors like vi, vim, gvim, and gedit (and possibly others I'm not aware of) can all accept the output of a command as the "file" being edited.
For example, you can direct the output of a grep command to gvim with the following command:
grep searchPattern | gvim -
If you really want to get fancy, you can pass a command to gvim to cause it to search for the same pattern you used grep to find by using the -c argument.
grep searchPattern | gvim -c/searchPattern -
Since searchPattern appears twice on the command line and engineers never want to type any extra characters, I'd define a command alias to perform this action. Since there are so many shells out there, I'll leave that as an exercise for the reader.
This blog is intended to give me a place to comment on things which strike my fancy, hence the title. Topics may include computer software or hardware, science, space, books, movies, television programs of a geeky nature, or almost anything else.
Subscribe to:
Post Comments (Atom)
-
A long time ago I was given a bit of advice that has served me well over the years. An engineer with much more experience than I had at the...
-
We lost our very special dog to an osteosarcoma a few days ago. He started limping a little over 4 months ago and it took a while to dia...
-
Most of the longtime Unix users like me love grep. Regular expressions make the silly wildcards available in Windows seem completely underw...
No comments:
Post a Comment