![]() ![]() So if grep returns nothing, that means that it couldn’t find the word you are searching for. If the Documents folder didn’t exist, grep wouldn’t return any output. $ ls | grep DocumentsĪs you can see in the screenshot above, using the grep command saved us time by quickly isolating the word we searched for from the rest of the unnecessary output that the ls command produced. Let’s look in our home directory for a folder called Documents.Īnd now, let’s try checking the directory again, but this time using grep to check specifically for the Documents folder. That’s something you would use the “ls” command for.īut, to make this whole process of checking the directory’s contents even faster, you can pipe the output of the ls command to the grep command. Say that you need to check the contents of a directory to see if a certain file exists there. Let’s look at some really common examples. You can use it to search a file for a certain word or combination of words, or you can pipe the output of other Linux commands to grep, so grep can show you only the output that you need to see. Save my name, email, and website in this browser for the next time I comment.Grep is a command-line tool that Linux users use to search for strings of text. Your email address will not be published. ![]() Command to find “ERROR” or “DEBUG” in applicationLog.log file 14:20:13.966 INFO-DEBUG 1051 - o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path onto handler of type ġ. 14:20:13.921 INFO 1051 - s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped “” onto public .ModelAndView .(, 14:20:13.807 DEBUG 1051 - s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for 4c624d60: startup date root of context hierarchy 14:20:13.441 INFO 1051 - o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: ‘requestContextFilter’ to: 14:20:13.436 WARNING 1051 - o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: ‘dispatcherServlet’ to 14:20:13.240 INFO 1051 - o.s. : Root WebApplicationContext: initialization completed in 2629 ms : Initializing Spring embedded WebApplicationContext Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. 14:20:13.227 INFO 1051 - .TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. 14:20:12.725 INFO 1051 - .StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14 14:20:12.697 ERROR 1051 - s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) :: Spring Boot :: (v1.5.3.RELEASE) 14:20:10.519 INFO 1051 - o.a.j.SpringBootHelloWorldApplication : Starting SpringBootHelloWorldApplication on apples-MacBook-Air.local with PID 1051 (/Users/apple/Documents/WorkspaceAlgo/SpringBootHelloWorldExample/target/classes started by apple in /Users/apple/Documents/WorkspaceAlgo/SpringBootHelloWorldExample) Let’s say your application is deployed on linux machine and you need do analysis of log file and you need to find lines with the specific words in it.įor example: you want to find all the lines with “ WARNING” or “ DEBUG” words in it. In this post, we will see how to grep multiple Strings in linux.
0 Comments
Leave a Reply. |