Introduction
Please keep in mind that cPanel Support is not able to provide support for the use of system utilities such as grep and find. This guide is provided as a courtesy only. If you have additional questions about how to use these utilities to accomplish a particular task, you must consult with a systems administrator with the skills, training, and expertise required to do so for you.
You also have the option of reviewing the manual pages for these standard utilities:
Procedure
1. Login to SSH or Terminal as the root user
2. Run the following command where YOURSEARCHTERMHERE should be replaced with whatever you are searching the access logs for.
find /etc/apache2/logs/domlogs/*/ -type f -exec grep --with-filename YOURSEARCHTERMHERE {} \;
In the above command the -type flag tells find to only return files and skip directories.
The -exec command tells find that it should execute something on each file.
The command to be executed on each file is the grep command.
The --with-filename flag prints the filename before each line that matches your search query. Without this flag, you would not be able to determine which file contains whatever was found by grep.
The {} characters are a part of the find command. Those characters tell find to use the filename of each log it finds in that location so that the grep command knows which file to search on each iteration.
The \; characters tell the find command that you have finished writing out the grep command.
If you have additional questions about how this works, please review the manual pages for these commands or reach out to a systems administrator.
Comments
0 comments
Article is closed for comments.