Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash grep only return first match

# Basic syntax:
grep -m 1 "pattern" input_file.txt
# Where -m is the maximum number of matching lines to return, i.e. stop
#	reading the file after m matches
# Note, this is more efficient than piping to head because there you
#	always read the whole file even if you're only looking for m matches
Comment

grep first match

Just combine grep with head command for filtering  only the first match as:
grep "match" | head -n 1   #Change 1 to not only match first but further matches
Comment

PREVIOUS NEXT
Code Example
Shell :: free code camp offline 
Shell :: search in github repo 
Shell :: add geckodriver to path linux 
Shell :: linux tar.gz 
Shell :: changed files git 
Shell :: touch command not recognized in windows 
Shell :: the most profitable business in zimbabwe 
Shell :: export environment variable from bash script 
Shell :: install choco 
Shell :: delete all folders except one linux 
Shell :: committing on github 
Shell :: docker compose install 
Shell :: read -p linux 
Shell :: sed add line to file 
Shell :: grep Matching options 
Shell :: add one drive to ubuntu 
Shell :: install ignite-cli 
Shell :: add new file to context menu win 10 11 
Shell :: twisted.internet.error.ReactorAlreadyInstalledError: reactor already installed [5804] Failed to execute script main 
Shell :: 28 essential aws s3 command line 
Shell :: github shows two icons on commit 
Php :: magento 2 create admin user 
Php :: php refresh 
Php :: disable laravel debugbar 
Php :: smarty assign var 
Php :: how to migrate just one table in laravel 
Php :: Example wp-config.php for Debugging 
Php :: laravel change post request before save 
Php :: php get next saturday 
Php :: laravel route group middleware prefix 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =