I want to modify the IP in two files:
Contents of File1 has this line:
AS400=127.0.0.1
Contents of File2 has this line:
AS400=127.0.0.1
The bash script below will ask me the IP address of the AS400 and at this time only modify one file:
#!/bin/bash
# Modify props file - file1.props
echo " Please answer the following question"
gawk -F"=" 'BEGIN{
printf "Enter AS400 IP: "
getline as400 <"-"
file="/usr/local/src/file1.props"
}
/as400/ {$0="as400="as400}
{
print $0 > "temp2"
}
END{
cmd="mv temp2 "file
system(cmd)
}
' /usr/local/src/file1.props
How do I tell it to update the exact same IP address I type in to file2 also?
Bonus question... Can anyone take a look at this script and tell me why the file getting edited ends up with a ^M at the end of each line?