Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

Perl or Unix Shell script to replace 4th column value to the left of a specific text in a csv file

Refer to the attached sample file;  my actual file has thousands of lines of the same
format.

I need a script urgently that would allow me to
a) search a specific (case-sensitive) text in the last column of the csv file (script is to
     allow me to input the text as the 1st parameter)
b) then for the 4th column in the csv file, replace the value with another value
    (this new value is to be taken as a parameter).

So, for example, if your script is called  replvalue.pl or replvalue.sh,
then I just need to execute it as :

# replvalue.pl "CPUTotalLoad Repaired" 3.0
so the above wud change the last line of the csv to :
2898,29/4/2010  9:12:27 AM,664.8,3.0,,Medium,UNIX-HP,Globl Ops,29/4/2010  8:17:54 PM,665.4,29/4/2010  8:17:44 PM,incident,,UKOPPMB2.AG.UK UxsA2_CPUTotalLoad Repaired Critical
egcsv.txt
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial