![]() ![]() Search for Invert Match using grep commandĪnother nice feature we have in grep command is invert search. txt filesĪ.txt:linux is a open source operating system.ī.txt:Linux is a Open Source Operating System.Ĭ.txt:LINUX IS A OPEN SOURCE OPERATING SYSTEM. Syntax : grep -i data]# lsĪ.txt b.txt data]# grep -i linux *.txt # Searching from all. For example here I am searching for string linux from all available text files. We can use wildcard to search with grep command. Search for a String in Multiple Files using Wild Card ~]# grep -i 'linux\|elinuxbook\|Open' file.txt # Search for Multiple Strings data]# data]# lsĪ.txt data]# grep -color -i linux a.txt b.txt # Searching from Multiple FilesĪ.txt: linux is a open source operating system.ī.txt: Linux is a Open Source Operating System. You can see on the output below we are able to search for the string linux from both the files and the output show’s the searched string with the file name from which it searched. and I am going to search for string linux from both the files. Here I have a directory named data which contains two files i.e. You can search for a string from multiple files. Search a String in Multiple Files using grep command MANAGING USERS AND GROUPS IN LINUX – A COMPLETE GUIDE FOR BEGINNERS.~]# grep -color -i linux file.txt # Searching for Case Insensitive Strings Linux is a Open Source Operating System. Here I am searching for string linux and you will able to notice on output below that I able to search all the strings whether it contains Uppercase or Lowercase. We can search Case Insensitive strings using grep command with argument -i. Search for Case Insensitive strings using grep command ~]# rpm -qa | grep vsftpd # Searching for a Installed Package Here I am searching if vsftpd package is installed or not. You also can search for a Installed Package. ~]# cat /etc/passwd | grep -color elinuxbook # Searching for a User using grep CommandĮlinuxbook:x:501:501::/home/elinuxbook:/bin/bash Here I am searching for user elinuxbook in /etc/passwd file using grep command. ~]# grep -color linux file.txt # Search for string by Highlighting it with color linux is a open source operating system. Search for a string by highlighting in color using grep command with option – -color. ~]# grep linux file.txt # Search for a String
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |