The Linux syntax to find string in files is as follows:
$ grep "text string to search" directory-path
$ grep [option] "text string to search" directory-path
$ grep -r "text string to search" /directory-path
$ grep -r -H "text string to search" directory-path
$ grep -E -R "word-1|word-2" /path/to/directory
# Find string in files on Linux #
$ grep -E -w -R "word-1|word-2" directory-path
all text (*.txt) files located in directory
grep “redeem reward” ~/*.txt
Search all subdirectories recursively
grep -r “redeem reward” /home/tom/
search whole server
sudo grep -R “barfoo” /
search specific directory
sudo grep -R “barfoo” /etc/
nginx: configuration file /etc/nginx/nginx.conf test failed
root@srv443573:~# nginx -t
nginx: [warn] conflicting server name “sarkariplex.com” on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name “sarkariplex.com” on [::]:80, ignored
nginx: [warn] conflicting server name “sarkariplex.com” on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name “sarkariplex.com” on [::]:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@srv443573:~# cd /etc/nginx/sites-enabled
root@srv443573:/etc/nginx/sites-enabled#
grep -nr ‘sarkariplex.com’
root@srv443573:/etc/nginx/sites-enabled# grep -nr ‘sarkariplex.com’
custom-domain.conf:8: server_name sarkariplex.com;
apicetorgin.conf:20: root /home/splex/htdocs/sarkariplex.com;
apicetorgin.conf:92: root /home/splex/htdocs/sarkariplex.com;
jobsarkariresultz.conf:20: #root /home/splex/htdocs/sarkariplex.com;
jobsarkariresultz.conf:21:return 301 https://sarkariplex.com;
jobsarkariresultz.conf:93: root /home/splex/htdocs/sarkariplex.com;
ff.sarkariplex.com.conf:6: ssl_certificate_key /etc/nginx/ssl-certificates/ff.sarkariplex.com.key;
ff.sarkariplex.com.conf:7: ssl_certificate /etc/nginx/ssl-certificates/ff.sarkariplex.com.crt;
ff.sarkariplex.com.conf:8: server_name ff.sarkariplex.com;
ff.sarkariplex.com.conf:9: root /home/fff/htdocs/ff.sarkariplex.com;
sarkariplex.com.conf:6: ssl_certificate_key /etc/nginx/ssl-certificates/sarkariplex.com.key;
sarkariplex.com.conf:7: ssl_certificate /etc/nginx/ssl-certificates/sarkariplex.com.crt;
sarkariplex.com.conf:8: server_name www.sarkariplex.com;
sarkariplex.com.conf:9: return 301 https://sarkariplex.com$request_uri;
sarkariplex.com.conf:17: ssl_certificate_key /etc/nginx/ssl-certificates/sarkariplex.com.key;
sarkariplex.com.conf:18: ssl_certificate /etc/nginx/ssl-certificates/sarkariplex.com.crt;
sarkariplex.com.conf:19: server_name sarkariplex.com www1.sarkariplex.com;
sarkariplex.com.conf:20: root /home/splex/htdocs/sarkariplex.com;
sarkariplex.com.conf:91: server_name sarkariplex.com www1.sarkariplex.com;
sarkariplex.com.conf:92: root /home/splex/htdocs/sarkariplex.com;
sarkarily.com.conf:20: root /home/splex/htdocs/sarkariplex.com;
sarkarily.com.conf:92: root /home/splex/htdocs/sarkariplex.com;
sarkariresultz.conf:20: root /home/splex/htdocs/sarkariplex.com;
sarkariresultz.conf:92: root /home/splex/htdocs/sarkariplex.com;
root@srv443573:/etc/nginx/sites-enabled#
grep -nr ‘server_name sarkariplex.com’
after removing duplicate
root@srv443573:/etc/nginx/sites-enabled# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful