Edit line a textfile using linux shell -


i need change ip-address in text-file using linux-shell. how can that? know great source regular expressions?

the textfile.txt contains sth this:

# text text ffeefe  whatever text text ffeefe  # text text ffeefe  # ipaddress : 192.168.200.40 # # text text ffeefe # whatever text text ffeefe  # text text ffeefe  

this looking for:

sed -i / find xxx.xxx.xxx.xxx / 192.168.200.41 / textfile.txt 

the ip in format xxx.xxx.xxx.xxx e.g. 192.168.200.40

although fedorqui right asking more information occurring of ip after specific content, i'll provide (easy) solution finding ipv4 string.

the expression is:

[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ 

using in sed looks this:

sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/newip/' file 

on other hand, if fixed "ipaddress : " before ip, op should use ip want.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -