Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash find files with word

# 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 :: windows how to run sh script 
Shell :: sed replace from match 
Shell :: To install the GNOME desktop environment 
Shell :: grep first match 
Shell :: vscode command line run 
Shell :: run anydesk from terminal ubuntu 
Shell :: change git 
Shell :: install lua in ubuntu 
Shell :: grub customizer 
Shell :: setup mongodb locally on centos 8 
Shell :: ubuntu extract .tar.xz file 
Shell :: committing on github 
Shell :: grep in multiple files 
Shell :: how to create an alias in bash 
Shell :: run emulator from command line 
Shell :: linux unpack gz 
Shell :: install cockroachdb linux 
Shell :: error installing cocoapods mac 
Shell :: linux copy files terminal cp -r 
Shell :: download stardocks sdk from nuget package 
Shell :: https://cloud.google.com/shell/docs/using-web-preview#previewing_the_application 
Shell :: apt mailbox debian 10 
Php :: tinker not colorful 
Php :: wpdb last query 
Php :: destroy session codeigniter 3 
Php :: eloquent get random 
Php :: Library not loaded: /usr/local/opt/icu4c/lib/libicuio.64.dylib Referenced from: /usr/local/bin/php 
Php :: php time a script 
Php :: hasany cakephp 
Php :: whereNull in laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =