Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

grep lines after match

$ grep -A1 text

-AX tells grep to display 'X' amount of lines after line of match. 
Use -BX to do the same but before.
Comment

grep line after match

Include -A flag to add lines after match and -B flag to add lines before
grep match -A 3	#display match line and 3 after lines
grep match -B 2 #display match line and 2 lines before
Comment

grep all lines until match

sed -n -e '/Word A/,/Word D/ p' file
Comment

grep lines before and after

# display 3 lines before and after matchline
rg -C 3 "keyword"
Comment

PREVIOUS NEXT
Code Example
Shell :: navigation in react native 
Shell :: how to setup wordpress in docker 
Shell :: how to run .sh script in mac 
Shell :: docker compose down single container 
Shell :: rmdir directory not empty 
Shell :: how to start mongodb server in ubuntu 
Shell :: base64 encode linux 
Shell :: github commit 
Shell :: conda install tokenizers 
Shell :: install raylib osx 
Shell :: install scikit learn 
Shell :: ubuntu drag and drop to desktop 
Shell :: bash get last field in line 
Shell :: where are paint 3d files saved 
Shell :: git revert one file 
Shell :: convertir a sudoers user centos 
Shell :: how to open .bin file in linux 
Shell :: conda install huggingface hub 
Shell :: sed add word to end of line 
Shell :: git checkout previous commit 
Shell :: jitsi run pod ios app !] Invalid `Podfile` file: cannot load such fil 
Shell :: git grep in commits 
Shell :: bash for loop parallel 
Shell :: service redis restart 
Shell :: vlc media player download for fedora 
Shell :: open port on firewall linux 
Shell :: arch linxu 
Shell :: bash else if 
Shell :: find files size greater than 100mb in linux 
Shell :: undo previous commit locally 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =