linux - Working with files in Expect -
i want read file contents, processing , write them file using expect
scripting tool.
let's assume have file_a contains following data:
the ip address of machine is: "0.0.0.0"
i want read contents of file_a, modify them , write them file_b, should following:
the ip address of machine is: "192.168.0.69"
can please me this?
you can use sed command replace file content below.then use move command make backup file want.
sed -i.bk 's/0.0.0.0/192.168.0.69/g' file_a.txt mv file_a.txt.bk file_b.txt
explanation:
sed = stream editor -i = in-place (i.e. save original file) command string:
s = substitute command
0.0.0.0 = regular expression describing word replace (or word itself)
192.168.0.69 = text replace with
g = global (i.e. replace , not first occurred
Comments
Post a Comment