Hi all,
Actually I have a huge bash file like:
port1=$PORT && if [ $port -eq "$NUM"]; then .....
....stuff
port2=$PORT && if [ $port -eq "$NUM"]; then .....
...stuff
port3=$PORT && if [ $port -eq "$NUM"]; then .....
...stuff
port4=$PORT && if [ $port -eq "$NUM"]; then .....
...stuff
port5=$PORT && if [ $port -eq "$NUM"]; then .....
I would like to change the $port inside the square brackets accordly to the beginning of line, by getting:
port1=$PORT && if [ $port1 -eq "$NUM"]; then .....
....stuff
port3=$PORT && if [ $port3 -eq "$NUM"]; then .....
...stuff
port8=$PORT && if [ $port8 -eq "$NUM"]; then .....
...stuff
port66=$PORT && if [ $port66 -eq "$NUM"]; then .....
...stuff
port5=$PORT && if [ $port5 -eq "$NUM"]; then .....
I was thinking to do that with sed but not able to work out a solution.
Any idea please?
Thanks in advance