Created
April 26, 2019 14:38
-
-
Save ChristianOellers/a01040070b85d7a3e4582e6f5e0735ed to your computer and use it in GitHub Desktop.
Magento E-Commerce CE - Bash snippets for searching through folders, file content and logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------------------------------------------------------------ General | |
# Recursively search through all folders and file contents. | |
# Note: It also searches in binary files. Change the command or limit it to code folders. | |
grep -lir 'example' . | |
# Limit search to PHP files only. | |
grep --include '*.php' -lir 'example' . | |
# Use REAL regular expressions instead of substrings and placeholders. | |
grep -E | |
# Inverse search: Only show what you did NOT search for. | |
grep -vE | |
# Show line number of result. | |
grep -n | |
-------------------------------------------------------------------------------------------------------------------------------- Server logs | |
# Search through all Magento server logs with focus on visited frontend pages. | |
# Exclude: Images, CSS, JS, XML (RSS); Admin panel calls | |
# /srv/www/magento/logs | |
grep -nvE '(\.jpg|\.gif|\.png|\.css|\.ico|\.js|/admin/|/rss/catalog)' access.log > result.log | |
# Search for certain dates and save the whole line in a new file. | |
grep '01/Jan' access.log > result.log | |
# Show all lines except those with specificied file extensions. | |
# The filtered result will mostly contain HTML and JS calls. | |
grep -nvE '(\.jpg|\.css)' access.log > result.log | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment