Locate a file which contains a string

I do face a ton of situation whereby i face an error while performing an installation on a Linux system and I need to solve the error, doing so requires me to locate a file (can be the installation file or system file) which contains a particular sentence (can be the error message or a particular configuration) in order for me to determine what should i need to perform next

Problem: I’m supposed to install a IBM product on a Rhel system. I know i have successfully installed the product in my Dev lab but when performing the installation in the production environment, the installer shell script keeps prompting the error “unknown command: installation.sh”. After troubleshooting the error i realized the customer had a Rhel system which is hardened! Means i would need to change the installer script to “sh < script_name>” for all the error i faced pertaining to this problem.

Solution: As i do not have the visibility of all the scripts which this installation file will potentially call, I need to have a command which allows me to search the script name whenever i faced the error.

grep -iHrn "<string to locate>" .

This command will search the path “.” (current working path) which will then return the path of the file which contains the string and line number

After which you can use the following command to edit the file

vi < path to file > +<line_number>

For my case, i will go to that line and add a “sh” before the shell script

Design a site like this with WordPress.com
Get started