|
|
useless use of cat!
I use cat like this all the time. You can try different search strings at the end of the command, using the up-arrow to recall the last bash command. Doesn't make sense for one search, but if you are going to try a bunch of differnet search strings, it's quick.
useless use of cat!
Merlyn's point is that you do not need to send the file(s) through
cat in order to grep them. Just leave out the cat part and grep the files with
It even works with wildcards and other shell patterns. Try it (and check out -Mark
useless use of cat!
Both ways do the same thing and of course omitting a "useless" `cat` would be more efficient, but assuming you will be repeating the command several times with different search strings, it's much easier to arrow back from the end of the line only a few characters, rather than all the way through the filename, especially if the filename is a hundred or so characters long when the path is included. eg:
In that example, the second line only requires pressing the up arrow key once, the left arrow key once, then typing the string 'for'. The other way, `grep 'somethingtosearch' some_long_file_name.txt` would require arrowing all the way back through the file name, or else doing ctrl-a and arrowing all the way forward through the search string. So, really, the usage of `cat` in the original example does have a good use under certain circumstances.
useless use of cat!
better use of history
if you are going to try a bunch of differnet search strings, it's quick A better idiom:
"!$" means "last argument of the previous command". See the bash manpage for other (highly useful) history tokens.
better use of history
You can also use
to access the last argument.
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:Hints1 new Hints in the last 24 hoursComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.06 seconds |
|