Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of sunhux
sunhux asked on
Unix OSPerlShell Scripting
3 Comments1 Solution1620 ViewsLast Modified:
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