grep first match
Just use flag -m to define number of occurrences to match:
grep -m1 pattern file#Combine grep and tail for grepping until second match and filtering
#last with tail command
grep -m2 "two" in-file.txt | tail -n1Just 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
Also in C++:
- Title
- bash search and replace text in file
- Category
- C++
- Title
- git remove added file
- Category
- C++
- Title
- There is no application installed for “shared library” files
- Category
- C++
- Title
- git commit number of lines changed
- Category
- C++
- Title
- best free web hosting online
- Category
- C++
- Title
- bash "=~" example
- Category
- C++
- Title
- powershell try catch connect-viserver
- Category
- C++
- Title
- awk
- Category
- C++
- Title
- how to create a guid in powershell
- Category
- C++
- Title
- install vim in wsl
- Category
- C++
- Title
- remove a remote origin git
- Category
- C++
- Title
- importerror cannot import name 'monitoring' from 'tensorflow python eager
- Category
- C++
- Title
- how to add filer to git ignore
- Category
- C++
- Title
- ubuntu mate 20.04 videodev module not working
- Category
- C++
- Title
- bash how to copy or move all files in a list
- Category
- C++
- Title
- show version laravel
- Category
- C++
- Title
- bash split string into variables
- Category
- C++
- Title
- awk if else statement
- Category
- C++
- Title
- how to kill port in ubuntu
- Category
- C++
- Title
- redis ubuntu install
- Category
- C++
- Title
- installed delphi package says unit not found
- Category
- C++
- Title
- force logrotate linux
- Category
- C++
- Title
- check user group console linux
- Category
- C++
- Title
- retroarch for ubuntu
- Category
- C++