Bash sed: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
| mNo edit summary | mNo edit summary | ||
| Line 6: | Line 6: | ||
| cat foo | sed "/^stringMatch2/q" | grep -v "^stringMatch2" | cat foo | sed "/^stringMatch2/q" | grep -v "^stringMatch2" | ||
| * will match ALL until match ( and remove match string LINE) | * will match ALL until match ( and remove match string LINE) | ||
| echo "192.168.15.58 172.17.0.1 123.10.130.201" | sed 's/172.[[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+//' | |||
| 192.168.15.58  123.10.130.201 | |||
| * Will strip out IP addresses beginning with 172. | |||
| [[Category:bash]] | [[Category:bash]] | ||
Revision as of 11:22, 24 August 2022
Useful sed commands
cat foo | sed "1,/^stringMatch/d"
- Will ignore all before string match until EOF
- stringMatch must be start of line (^)
cat foo | sed "/^stringMatch2/q" | grep -v "^stringMatch2"
- will match ALL until match ( and remove match string LINE)
echo "192.168.15.58 172.17.0.1 123.10.130.201" | sed 's/172.digit:\+.digit:\+.digit:\+//' 192.168.15.58 123.10.130.201
- Will strip out IP addresses beginning with 172.