To write shell script based on 1 and 4th columns

Hi,
I am trying to write shell script for below requirement
File has below values

  @mqm    soft    nproc     75000
  @mqm    hard    nproc     75000
  @mqm    soft    nofiles         76492
  @mqm    hard    nofiles         76492
  @mqm    soft    locks           76492
  @mqm    hard    locks           76492
  

I am writing shell script to achive if 1st column @mqm and 2,3rd columns are conditions then 4th columns values should check. If 4th columns values is less than above mentioned value then it should change to above mentioned value. If 4th column value is greater than above mention value then it should leave it.

When i run the script it should do above checks.
For example. let us ake First row
1st columns (@mqm) should check 2nd column (soft) then 3rd column(npproc) if it is pattern then it should check for 4th column value(75000). As 4th column value is Equal to 75000 then it should leave the value as it is if less than 75000 then it should change to 75000, if it is greater than 75000 (assume 80000) then it should leave as it is to 85000

Can you help me in achiveing or writing this script

If this is the benchmark data, provide us the input data that needs tobe verified with this

---------- Post updated at 10:00 AM ---------- Previous update was at 09:57 AM ----------

awk 'NR == FNR{a[$1 $2 $3] = $4; next}
  {if($4 < a[$1 $2 $3])
    $4 = a[$1 $2 $3]
  print $0}' benchmark_file input_file

[LEFT]Hi SriniShoo,

It is like hard coding, there won't be any input data. I am looking for script which checks the file and conditions. Based on conditions it should change the value.

assume script name is change.sh
when i run ./change.sh it will check the file which has given values in my first post(Assume file name is values.txt)

it should check 1st,2nd,3rd values (If you observe 2nd and 3rd values gets change). So if 1st,2nd,3rd values are (@mqm soft npproc) then it should check 4th column values is less than 75000 or not if yes it should change to 75000, if above 75000 it should leave.

Similarly for all 6 rows

Or else let me know with out hard coding is there any way to achive this
[/LEFT]

without seeing a desired output based on a sample input - just guessing....

awk '{idx=$1 $2 $3} FNR==NR{a[idx]=($4>a[idx])?$4:a[idx];next}{ $4=a[idx}1' values.txt values.txt

Somehow, I am unable to understand your requirement clearly
If you are only concerned about (@mqm soft npproc), below code will suffice
If your requirement is different, please provide proper input, along with expected output

awk '($1 " " $2 " " $3) == "@mqm soft npproc" {if($4 < 75000) $4 = 75000}1' file

Ok.. Let me explain you in detail. I have multiple unix servers and i have a file (security.txt) on all the servers. Security files will have values like below.
file: security.txt on 1.2.3.4

@mqm    soft    nproc     75000
@mqm    hard    nproc     85000
@mqm    soft    nofiles         76492
@mqm    hard    nofiles         86492
@mqm    soft    locks           66492

On all the servers security.txt file will not have same values. On few servers 4th Columns values will be lesser than standard values or greater than standard values.
Below are the standard values of security.txt

@mqm    soft    nproc     75000
@mqm    hard    nproc     75000
@mqm    soft    nofiles         76492
@mqm    hard    nofiles         76492
@mqm    soft    locks           76492
@mqm    hard    locks           76492

1.If 4th column values are lesser than standard values then when i run the script it should change to standard values
2.If 4th colums values are greater than standard values then it should leave the values as it is as those are greater than standard values.
3.If any of the row is not there in file then it should add that row in security.txt when i run the script (script.sh)

When i run the script (script.sh) on 1.2.3.4 expected output is like below

@mqm    soft    nproc     75000
@mqm    hard    nproc     85000 (Left this values as it is greater than standard value 75000)
@mqm    soft    nofiles         76492 
@mqm    hard    nofiles         86492 (Left this values as it is greater than standard value 76492)
@mqm    soft    locks           76492 (Changed this values to 76492 as earlier values is 66492)
@mqm    hard    locks           76492 (This row is added as this is not there in security.txt on 1.2.3.4)

create a 'standard.txt' file with the values you think are standard.

$ cat standard.txt
@mqm    soft    nproc   75000
@mqm    hard    nproc   75000
@mqm    soft    nofiles 76492
@mqm    hard    nofiles 76492
@mqm    soft    locks   76492
@mqm    hard    locks   76492
$

Now, you have a 'security.txt' file as below

$ cat security.txt
@mqm    soft    nproc   75000
@mqm    hard    nproc   85000
@mqm    soft    nofiles 76492
@mqm    hard    nofiles 86492
@mqm    soft    locks   66492
$

Run the below code

awk 'BEGIN {FS = OFS = "\t"}
  NR == FNR {a[$1 FS $2 FS $3] = $4;
  next}
  {if($4 < a[$1 FS $2 FS $3])
    {$4 = a[$1 FS $2 FS $3]}
  print
  delete a[$1 FS $2 FS $3]}
  END {for(x in a)
    {print x, a[x]}}' standard.txt security.txt

Below is the result when I ran the code on the files

$ awk 'BEGIN {FS = OFS = "\t"}
>   NR == FNR {a[$1 FS $2 FS $3] = $4;
>   next}
>   {if($4 < a[$1 FS $2 FS $3])
>     {$4 = a[$1 FS $2 FS $3]}
>   print
>   delete a[$1 FS $2 FS $3]}
>   END {for(x in a)
>     {print x, a[x]}}' standard.txt security.txt
@mqm    soft    nproc   75000
@mqm    hard    nproc   85000
@mqm    soft    nofiles 76492
@mqm    hard    nofiles 86492
@mqm    soft    locks   76492
@mqm    hard    locks   76492
$

Hi,
This is the output i got when i ran the script. New values are not added into file security.txt

$ chmod 777 script.sh
$ ./script.sh
@mqm    soft    nproc   75000
@mqm    hard    nproc   85000
@mqm    soft    nofiles 76492
@mqm    hard    nofiles 86492
@mqm    soft    locks   66492
@mqm    hard    nproc   75000
@mqm    hard    nofiles 76492
@mqm    hard    locks   76492
@mqm    soft    locks   76492