Is still a headache for not knowing how to use grep command, if you pass the instance, you can better grasp the usage of grep command, the following small series will introduce you to Linux using grep command For example, I hope to help you.
grep is a powerful Linux distribution preinstalled each file pattern search tool. For whatever reason, if your system does not pre-install it, you can easily install it through the system's package manager (apt-get in Debian/Ubuntu and yum in RHEl/CentOS/Fedora). .
$ sudo apt-get install grep #Debian/Ubuntu $ sudo yum install grep #RHEL/CentOS/Fedora
Instance:
1. Search and find files assuming you You have installed a brand new Ubuntu on your computer, and then you plan to uninstall Python. You browse the web for tutorials, but you find that there are two different versions of Python in use, and you don't know which version of Python your Ubuntu installer has installed on your system, or which modules it has installed. To solve this trouble, simply run the following command:
$ sudo dpkg -l |
Grep -i python
Output example
ii python2.7 2.7.3-0ubuntu3.4 Interactive high-level object-oriented language (version 2.7)
ii python2. 7-minimal 2.7.3-0ubuntu3.4 Minimal subset of the Python language (version 2.7)
ii python-openssl 0.12-1ubuntu2.1 Python wrapper around the OpenSSL library
ii python- Pam 0.4.2-12.2ubuntu4 A Python interface to the PAM library
First, we run dpkg -l to list the .deb packages installed on your system. Next, we use the pipeline to transfer the output to the command grep -i python. This step can be simply interpreted as passing the result to grep and filtering out all the items containing python and returning the result. The –i option is used to ignore case because grep is case sensitive. Using the option -i is a good habit unless you plan to do a more detailed search.
2. Search and filter files grep can also be used for searching and filtering in one or more files. Let's look at a scenario like this:
There is a problem with your Apache web server, and you have to find a post from many professional websites. The person who kindly responds to you asks you to paste the contents of your /etc/apache2/sites-available/default-ssl file. If you can remove all the comment lines, isn't it easier for you, the person who helped you, and all the people reading the file to find the problem? Of course you can do it easily! Just do this:
Previous12Next page Total 2 pages
Want to use RAID to install the system you need to install the raid driver first, but can not find t
We all know that the file encoding in Windows defaults to gbk or gb2312, but many u
Linux system hard disk after mounting the directory, usually will not modify it, but sometimes becau
The Linux command <yes” does not mean affirmative, but can be used to output characters. Th
Linux when installing PyCharm prompts can not start PyCharm error how to do?
How to install and configure CentOS 6.0 Kamailio
How to use the chown command to change the owner of the Linux file
The example of the su command in Linux explains
Linux configuration SSH service method
Knowledge about Linux file types and extensions
Linux system how to set up security management
Linux uses commands to clean large files. Steps
Ubuntu how to install and optimize SSD hard disk
How to customize the History output format for Linux systems
Windows XP virtual memory standard setting method
WinXP set up remote desktop connection method
How does Win10 open the task manager? Win10 open task manager method summary
Win7 above can sweep the detection initial version
How to enhance asp.net 1.1 /2.0 security - anti-cross-site attack
Computer system win10 system How many characters can the clipboard be pasted?
Microsoft released Win10 Anniversary SDK Preview Build 14332
Microsoft announced the best way to upgrade Win10's first anniversary update
Win10 window title bar height and scroll bar width how to set