9.7 C
Munich
Thursday, March 30, 2023

Grep command in Magento2 search file content with an update

Must read

Grep command in magento2 search file content with an update: Complete guide and clarification explained in simple way and step by step.

There is much use of the grep command. It helps to improve the various types of bug fixes just by the use of a simple grep command. Make sure your newly added code working properly before running this command for any production deployment.

With the help of the below different commands, you can figure out many more things very quickly.

Complete list regarding Grep command in magento2 search file content with an update

Use of grep command for checking the module status

php -f bin/magento module:status | grep 'Foomancustom\|module'

Output for the above command will check the status for module name Foomancustom

List of enabled modules:
Foomancustom_GoogleAnalyticsPlus
List of disabled modules:

How to count the output result “wc -l” at the end using the grep command.

$ grep -oi 'undefined index' system.log | wc -l

It is also useful for displaying 1000 rows at the beginning with the help of the below command

$ tail -n 1000 system.log | grep -i 'undefined index'

How in case of system log grep command use for different purposes.

For checking Array access using a key that does not exist

$ grep -i 'undefined index' system.log

How to use a variable that was not defined previously

$ grep -i 'undefined variable' system.log

It is also useful to debug output which is generated by Mage::log()

$ grep -i 'debug' system.log

How it is beneficial in figuring out permission issues of any kind.

$ grep -i 'permission denied' system.log

Finding missing template file in Magento 2

$ grep -i 'not valid template file' system.log

Helpful in Access non-object

$ grep -i 'trying to get property of non-object' system.log

For finding in function call regarding the missing argument.

$ grep -i 'missing argument' system.log

For finding invalid arguments in a loop.

$ grep -i 'invalid argument supplied' system.log

For finding all queries explained above.

$ cat system.log | egrep -i '(debug|notice: undefined|permission denied|not valid template file|trying to get property of non-object|missing argument|invalid argument supplied)'

How grep command is useful in case of regarding exception log.

In this all kind of command you have use end of command “exception.log”

How it is useful for XML issues

$ grep -i 'xml schema' exception.log

Helpful in gateway issue regarding specific Authorize.net and Paypal

$ grep -i 'paygate.*gateway' exception.log
$ grep -i 'paypal.*gateway' exception.log

How it is useful in figuring out curl issue

$ grep -i 'curl' exception.log

Also useful in getting all issues getting in the exception log

$ cat exception.log | egrep -i '(xml schema|paygate.*gateway|paypal.*gateway|curl)'

How to find last 10 errors getting in report files and grep to find different error message.

MySQL issues regarding connection

$ ls -1t | head -10 | xargs grep -i 'mysql server' -sl

Helpful in finding out the invalid field in the config

$ ls -1t | head -10 | xargs grep -i 'invalid config field' -sl

It is helpful in case of finding unable to read the response.

$ ls -1t | head -10 | xargs grep -i 'unable to read response' -sl

For External URLs redirect

$ ls -1t | head -10 | xargs grep -i 'external urls redirect' -sl

How grep command is very much useful in case of finding of missing files in Appache error logs

$ tail -n 1000 /var/log/httpd/{virtualhost}-error_log | grep -i 'file does not exist'
- Advertisement -spot_img

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest article