![]() It surrounds the matching string with the colour, thus resulting in enhanced output. However, when there are too many matches, finding the requested text in the search results can be difficult. Obviously all of these sorts of things can be done with other tools too, but I wanted to illustrate that there are some fun ways to use more general purpose languages like awk or perl here. T he grep command is the de facto tool for searching text files. If you have perl on your host is a very nice tool to learn and in a nutshell you can use it to tail multiple files. tail -f logfile grep -v -E INFODEBUG Finally, the MOTHER AND FATHER of all tailing tools is. ây là cách s dng c bn và hay gp nht, nu n gan bn mun tìm mt chui nào ó trong ch mt file duy nht thì có th. tail -f logfile grep -v INFO Show lines that do not contain the words INFO or DEBUG. ![]() Maybe you want a line number counter and just the 6th field? How about this: tail -f /var/log/messages | \ Tip tc tìm hiu v Linux, tôi s trình bày v lnh grep - nó gíup bn tìm chui trong file ch nh. Which will print the 6th through the last field of the output (fields are whitespace separated)Īnother similar idea is to use a perl one-liner: tail -f /var/log/messages | perl -ne "/myfilterword/ and print" You can expand on this by using the power of awk, for example: tail -f /var/log/messages | \Īwk '/myfilterword/ ' That works exactly the same as the example using grep. Here's a couple other ideas, which while not as simple, may offer some interesting additional flexibility:įirst, you can filter with awk instead of grep: tail -f /var/log/messages | awk '/myfilterword/'
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |