Skip to main content
Tweeted twitter.com/StackUnix/status/852490310651453440
added 23 characters in body; edited tags
Source Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441

I have an example below where I need to replace the column 9 value if it is less than 8 else exit or ignore using sed or awk function:

) in datadbs extent size 16 next size 4 lock mode row;

) in datadbs extent size 16 next size 4 lock mode row; 

If I use the below awk function it only prints the value I need in column 9, but I still want to maintain the sentence structure.

echo ") in datadbs extent size 16 next size 4 lock mode row;" | awk '{if ($9 < 8 ) print 8;}'

echo ") in datadbs extent size 16 next size 4 lock mode row;" | awk '{if ($9 < 8 ) print 8;}' 

OUTPUT:

8

8 

What I want is the below:

) in datadbs extent size 16 next size 8 lock mode row;

) in datadbs extent size 16 next size 8 lock mode row; 

I have an example below where I need to replace the column 9 value if it is less than 8 else exit or ignore using sed or awk function:

) in datadbs extent size 16 next size 4 lock mode row;

If I use the below awk function it only prints the value I need in column 9, but I still want to maintain the sentence structure.

echo ") in datadbs extent size 16 next size 4 lock mode row;" | awk '{if ($9 < 8 ) print 8;}'

OUTPUT:

8

What I want is the below:

) in datadbs extent size 16 next size 8 lock mode row;

I have an example below where I need to replace the column 9 value if it is less than 8 else exit or ignore using sed or awk function:

) in datadbs extent size 16 next size 4 lock mode row; 

If I use the below awk function it only prints the value I need in column 9, but I still want to maintain the sentence structure.

echo ") in datadbs extent size 16 next size 4 lock mode row;" | awk '{if ($9 < 8 ) print 8;}' 

OUTPUT:

8 

What I want is the below:

) in datadbs extent size 16 next size 8 lock mode row; 
Source Link

replace a word or number in a sentence that is less than 8 using awk or sed

I have an example below where I need to replace the column 9 value if it is less than 8 else exit or ignore using sed or awk function:

) in datadbs extent size 16 next size 4 lock mode row;

If I use the below awk function it only prints the value I need in column 9, but I still want to maintain the sentence structure.

echo ") in datadbs extent size 16 next size 4 lock mode row;" | awk '{if ($9 < 8 ) print 8;}'

OUTPUT:

8

What I want is the below:

) in datadbs extent size 16 next size 8 lock mode row;