AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Notice that, with multiple search areas, the returned results are tagged with each filename from which the result is found. We can simply add a list of files to the grep command for it to search. Search for the same string in multiple files. Notice that the word steve is simply returned in red to indicate it has been found in the file. The search criteria is case sensitive so ensure that you're searching correctly. Search test1 for the string steve using grep. The grep command syntax is simply grep followed by any arguments, then the string we wish to search for and then finally the location in which to search.ġ. Let’s start using grep in its most basic form. For example when debugging an error in a log file. Searching a file for a specific string is extremely useful. Then press CTRL + X, then Y and Enter to save and exit. Note that in this file we are using a capital letter at the start of Steve. Finally edit test4 to complete our test environment. Similar to test1 we will add a list of names on separate lines but this list will include the name steven. this is a long line of test that contains the name steveħ. In test2 we will add a single longer line of test containing the name steve. After editing in nano press control x to exit, press y to confirm the save and then press enter. Note that in test1 none of the names contain capitals. Edit test1 using nano to contain the following names on separate lines. Create 4 files, test1, test2, test3 and test4.
0 Comments
Read More
Leave a Reply. |