Replace char on text file

Hi ,

I have problem on replace char on text file

#!/bin/bash

echo "Enter Third value : "
read a

sed '2 s/192.160.1.1/cut -d"." -f3/$a/g' tcpip.txt > a.txt

I want replace line 2 on tcpip.txt with value a that I input but it's not run

Please help me

Search for 192.160.1.1 on line 2 of tcpip.txt, and replace 3rd value with contents of a:

sed "2 s/192.160.1.1/192.160.$a.1/" tcpip.txt > a.txt
1 Like

Thanks for your answer, it running well .