Sponsored Content
Top Forums Shell Programming and Scripting Update field value on a csv file Post 302847945 by midhun19 on Wednesday 28th of August 2013 05:43:01 AM
Old 08-28-2013
Update field value on a csv file

Hi
I have a job status csv file. I want to update the status of the job in the file.
Below is the csv file
Code:
 
1,jobname1,in_progress,starttime,somthing,somthing
2,jobname2,completed,starttime,somthing,somthing
3,jobname3,failed,starttime,somthing,somthing
4,jobname1,not_started,starttime,somthing,somthing

I want to update the status of the job in the file for a pattern "1,jobname1" from in_progress to completed. Basically i want to update the 3rd field value (what ever it may be) of the line which matches the pattern "1,jobname1" with "completed"

ie, after the update the file should look like
Code:
 
1,jobname1,completed,starttime,somthing,somthing
2,jobname2,completed,starttime,somthing,somthing
3,jobname3,failed,starttime,somthing,somthing
4,jobname1,not_started,starttime,somthing,somthing

can I do this with awk ?
Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to insert ' in a field in CSV file

print "count,pub,prodline,group,sector,date,source" > $fname cat sp_log.summary.$firstday-$lastday.ProdlineSector | sed "s/^ *//g;s/ *$//g" >sp_log.summary.$firstday-$lastday cat sp_log.summary.$firstday-$lastday | sed "s/$/ $lastyy-$lastmm cache/;s/ /,/g" >> $fname cat $fname | sed... (1 Reply)
Discussion started by: shikhakaul
1 Replies

2. Shell Programming and Scripting

replace a field in a CSV file

Hello all, I've a CSV file and need to replace 5th field if its value is "X". The exact requirement is to replace 5th field (column) with "Y" if a. it's value is "X" AND b. the line must start with ABC string i guess this can be done with awk. Pl help. For security reasons, the... (2 Replies)
Discussion started by: prvnrk
2 Replies

3. Shell Programming and Scripting

Command to create and update csv file

Hi, I need to create a csv file to store oracle query output. This report need to be created on hourly basis. The csv file report format as "Report_22_Sep_09_13IST.csv". I have the oracle query. Now i need to create and move the oracle query output to the report row by row starting from 3rd row.... (6 Replies)
Discussion started by: Sekar1
6 Replies

4. Shell Programming and Scripting

how to update a .csv file?

Hi everyone, im a newbie so plz bare with me, i have this txt file which contains an output of a query from oracle. now i copied the string inside this txt file in a .csv file. i used this command in doing this process: echo "Fatal alerts:", $(cat a.txt) > test.csv now what i want to... (1 Reply)
Discussion started by: 4dirk1
1 Replies

5. Shell Programming and Scripting

Update a field in a file based on condition

Hi i am new to scripting. i have a file file.dat with content as : CONTENT_STORAGE PERCENTAGE FLAG: /storage_01 64% 0 /storage_02 17% 1 I need to update the value of FLAG for a particular CONTENT_STORAGE value I have written the following code #!/bin/sh threshold=20... (1 Reply)
Discussion started by: kichu
1 Replies

6. UNIX for Dummies Questions & Answers

Update a CSV file with a predetermined value

Hi All Thanks for all your post and advice, you have been extremely helpful in the past. I have an issue where I'm stumped and am seeking a wider opinion. I'm relatively new to unix and have been tasked with collating a vast amount of data and presenting it within excel. Now the... (5 Replies)
Discussion started by: drestarr96
5 Replies

7. Shell Programming and Scripting

Update the table using values from a csv file

i want to run update query for oracle which is in up.sql taking values from a.csv. I have implemented shell script to do it. extn="perl" ls -1 | while read file do echo "$file,$extn" > a.csv done up.sql contains update file_list set filename=$1 where extn=$2; The code to update is... (2 Replies)
Discussion started by: millan
2 Replies

8. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

9. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies

10. Shell Programming and Scripting

awk to update value in field of out file using contents of another Ask

In the out.txt below I am trying to use awk to update the contents of $9.. If $9 contains a + or - then $8 of out.txt is used as a key to lookup in $2 of file. When a match ( there will always be one) is found the $3 value of that file is used to update $9 of out.txt separated by a :. So the... (6 Replies)
Discussion started by: cmccabe
6 Replies
shishi_kdcreq_postdated_p(3)					      shishi					      shishi_kdcreq_postdated_p(3)

NAME
shishi_kdcreq_postdated_p - API function SYNOPSIS
#include <shishi.h> int shishi_kdcreq_postdated_p(Shishi * handle, Shishi_asn1 kdcreq); ARGUMENTS
Shishi * handle shishi handle as allocated by shishi_init(). Shishi_asn1 kdcreq KDC-REQ variable to get kdc-options field from. DESCRIPTION
Determine if KDC-Option postdated flag is set. The POSTDATED option indicates that this is a request for a postdated ticket. This option will only be honored if the ticket-granting ticket on which it is based has its MAY-POSTDATE flag set. The resulting ticket will also have its INVALID flag set, and that flag may be reset by a subsequent request to the KDC after the starttime in the ticket has been reached. RETURN VALUE
Returns non-0 iff postdated flag is set in KDC-REQ. REPORTING BUGS
Report bugs to <bug-shishi@gnu.org>. COPYRIGHT
Copyright (C) 2002-2010 Simon Josefsson. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. SEE ALSO
The full documentation for shishi is maintained as a Texinfo manual. If the info and shishi programs are properly installed at your site, the command info shishi should give you access to the complete manual. shishi 1.0.1 shishi_kdcreq_postdated_p(3)
All times are GMT -4. The time now is 02:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy