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 :: create tar 
Shell :: CUDA_HOME environment variable is not set. Please set it to your CUDA install root. 
Shell :: ubuntu install github 
Shell :: bash script check if enough available disk space 
Shell :: ubuntu fingerprint sudo 
Shell :: error mounting dev sdb1 at media on ubuntu 
Shell :: composer install drupal drush 
Shell :: angular 
Shell :: IP adress terminal 
Shell :: loopback install 
Shell :: how to activate utf16 in powershell 
Shell :: ubuntu empty swap 
Shell :: extract rockyou.txt kali linux 
Shell :: brew install notion 
Shell :: yarn upgrade typescript 
Shell :: install ffmpeg ubuntu 
Shell :: how to restart docker linux 
Shell :: wsl windows 
Shell :: ssh connect to host bitbucket.org port 22: Connection timed out 
Shell :: how to clear log files linux debian 
Shell :: listen tcp 127.0.0.1:8001: bind: address already in use 
Shell :: git set url with user name and password 
Shell :: install chrome linux apt 
Shell :: sed get substring between two characters 
Shell :: install github linux 
Shell :: Bashrc use modules 
Shell :: install pi hole cmd 
Shell :: set git credentials so that i never ask for username and password while pushin 
Shell :: powershell get ip from computer name 
Shell :: understand the user of git in terminal 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =