I have this file:
this is line 1 192.168.1.1 this is line 2 192.168.1.2 this is line 3 192.168.1.2 this is line 4 192.168.1.1 this is line 5 192.168.1.2 I would like to get, in a bash script, all lines (with tabs) which contains, for example, the pattern "192.168.1.1". By this way, I would get:
this is line 1 192.168.1.1 this is line 4 192.168.1.1 But i don't want this result:
this is line 1 192.168.1.1 this is line 4 192.168.1.1 I tried it with sed without success:
var='192.168.1.1' body=`sed -n -e '/$var/p' $file` echo $body Thanks beforehand!