1

File contains

TIMEOUT=abc
TIMEOUT=5
TIMEOUT=
xTIMEOUT=5

I need to change from

"TIMEOUT=5" 

to

"TIMEOUT=9"

This command works.
But changes 4th line too, which is not desired

awk '$0 ~ "TIMEOUT=[:0-9:]" { $0 = "TIMEOUT=9" } {print}' file

And this command does not change anything

awk '$0 == "TIMEOUT=[:0-9:]" { $0 = "TIMEOUT=9" } {print}' file

What should I do? THANKS!

muru
  • 69,900
  • 13
  • 192
  • 292
Shila
  • 11
  • 1

1 Answers1

1

This should do:

awk '/^TIMEOUT=[:0-9:]/ { $0 = "TIMEOUT=9" } {print}' file

or even easier:

sed 's/^TIMEOUT=[0-9]/TIMEOUT=9/' file
Stephen Rauch
  • 4,209
  • 14
  • 22
  • 32