Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash find all files containing string

grep -r '/path/to/somewhere/' -e 'pattern'
Comment

bash find files containing string

# Basic syntax using find..exec:
find /top/dir -mindepth int -maxdepth int -type f -exec grep -H 'string' {} ;
# Note, this might look a bit scary, but it's worth learning
# Where:
#	- find searches recursively through all directories in the /top/directory
#	- -mindepth and maxdepth set the depth of subdirectories to search
#	- -type f indicates that only files should be considered
#	- all files found using the above criteria are iteratively passed to exec 
#		via the curly braces. exec then runs grep which searches for the word
#		'string' in the file
#	- -H tells grep to return the filename along with the matching line

# Basic syntax using find and xargs:
find /top/dir -mindepth int -maxdepth int -type f | xargs grep -H 'string'
# Note, more recently I've been using xargs which is faster and uses syntax
# 	that is, IMO easier to remember than exec
Comment

PREVIOUS NEXT
Code Example
Shell :: linux change default gateway 
Shell :: bash print one line until match 
Shell :: how to clone repo with all branches 
Shell :: grep until third match 
Shell :: linux-armv6l nodejs 
Shell :: linux tar.gz 
Shell :: change github 
Shell :: see wifi password 
Shell :: docker --restart example 
Shell :: grep search match in all files in folder 
Shell :: pyglet linux 
Shell :: can i merge two repositories github 
Shell :: first commit github 
Shell :: how to push to a new branch in gitlab 
Shell :: ubuntu install Qsampler 
Shell :: sleep until time bash 
Shell :: clone docker image 
Shell :: reinstall all tables doctrine 
Shell :: shut down linux keyboard shortcut 
Shell :: statistical inference project part 1 github 
Shell :: where do i grab someones powershell code 
Shell :: getssl 
Php :: how to make a php info 
Php :: laravel order by random 
Php :: codeigniter distinct 
Php :: check if user is on mobile php 
Php :: php hide notice 
Php :: php time script 
Php :: how to show validation error in laravel blade 
Php :: try and catch laravel 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =