Substitution problem.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substitution problem.
# 1  
Old 04-03-2007
Error Substitution problem.

Hi,
Just need some help in this.
Suppose there is one file a.txt, which contains this data:

"25187","00000022","00",28-MAR-2007,"" ,"D",-000001550,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,29-MAR-2007
613TB.STEXTRF1
"25187","0000004H","00",29-MAR-2007,"" ,"H",-001769013,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,29-MAR-2007

I need to substitute the value in the last value i.e. 29-MAR-2007 of every row with 02-APR-2007 so that it becomes
"25187","00000022","00",28-MAR-2007,"" ,"D",-000001550,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,02-APR2007
613TB.STEXTRF1
"25187","0000004H","00",29-MAR-2007,"" ,"H",-001769013,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,02-APR-2007

how can I do it in awk.
Please help.

Regards
Ashu
# 2  
Old 04-03-2007
Code:
awk -F"," -v OFS="," ' { sub("29-MAR-2007","02-APR-2007",$NF); $1=$1; print } ' file


Last edited by anbu23; 04-03-2007 at 08:22 AM..
# 3  
Old 04-03-2007
Thanks a lot.
# 4  
Old 04-03-2007
in perl:
Code:
$ perl -pi -e 's/29-MAR-2007(\s+)$/02-APR-2007\1/' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Variable substitution problem

HI i was studying about variable substitution. below are info which was given in a online tutorial. ${parameter:-word}---> If parameter is null or unset, word is substituted for parameter. The value of parameter does not change. ${parameter:=word}---> If parameter is null or... (3 Replies)
Discussion started by: scriptor
3 Replies

2. Shell Programming and Scripting

Problem with process substitution

i have tried process substitution, but run in some problems. this works: samtools view -h $SAMdir/$b.bam | htseq-count -m union -s no -q -t exon -i gene_id - $gtf > $b.count & but this not: htseq-count -m union -s no -q -t exon -i gene_id <(samtools view -h $SAMdir/$b.bam) $gtf >... (7 Replies)
Discussion started by: dietmar13
7 Replies

3. Shell Programming and Scripting

Problem with substitution in sed??

Hi alll I have a file with this content ale,AAM,id2_1_2_1_1,23,2013-01-30,1,1 ale,BAND,id2_1_1_1_1,31,2013-01-28,1,1 ale,CAI,id2_1_1_1_1,23,2013-01-28,1,1 ale,CAI,id2_1_1_1_4,23,2013-01-28,1,1 ale,CAI,id2_1_2_1_1,23,2013-01-30,2,1 ale,NAST,id2_1_1_1_1,23,2013-01-29,1,1... (1 Reply)
Discussion started by: nikhil jain
1 Replies

4. Shell Programming and Scripting

sed substitution problem

I'm writing my first script and I have all the other commands I'm using working properly, but I'm having one final issue with a sed. I've looked on the forums for some answers, which have been close but sed is quite confusing to me. My problem is that I have a file called CylinderAtom1.txt... (3 Replies)
Discussion started by: 1Aegis1
3 Replies

5. Shell Programming and Scripting

Another substitution problem

Hello again, I'm trying to change the following line: INSERT INTO PH1_TX_LOAD VALUES ('TX-78731-AABSS:4182-4','RH: GUIDE TO TENNIS',TO_DATE('18-JUN-2001:00:00:00', 'DD-MON-YYYY:HH24:MI:SS'),TO_DATE('21-JUN-2001:00:00:00', 'DD-MON-YYYY:HH24:MI:SS'),500) so that any TO_DATE is taken... (6 Replies)
Discussion started by: user_invalid
6 Replies

6. Shell Programming and Scripting

problem in dollar substitution

Hi, I have a problem in dollar substitution:- $ csv1="first_csv" $ csvnumber=1 $ echo {csv$csvnumber} {csv1} $ echo "${csv$csvnumber}" bad substitution I want first_csv...why is it not working thanks (2 Replies)
Discussion started by: scripter12
2 Replies

7. Shell Programming and Scripting

Crontab command substitution problem

Hi all, I am using Ubuntu 8.04 Linux. I have a cron job entry to run a shell script at a scheduled time. This script has a X application to be launched. As cron does not pick already exported environment variables and it runs in a separate environment, I need to export the DISPLAY variable to... (9 Replies)
Discussion started by: royalibrahim
9 Replies

8. Shell Programming and Scripting

sed substitution problem

Can anyone please help me on this. i have a file with lines say X X3200 X X X X2400 X X4100 I want to use sed to put the numbers in braces. the output should be like, X X(3200) X X X X(2400) X X(4100) (7 Replies)
Discussion started by: diliphp
7 Replies

9. Shell Programming and Scripting

Problem with sed string substitution

Hi, heres my problem: echo "aaaa(aaaa(aaa" | sed 's/a.*(//g' gives aaa but it should give aaaa(aaa .*( should find any string to the appearance of (, but it finds any string to the last appearance, any idea why, and how to do this? and what if the string ist... (2 Replies)
Discussion started by: funksen
2 Replies

10. AIX

VI Substitution problem

I'm having a problem getting my variables to work in dishing out an RMC script. The $1 works fine. $2 does not Here's a portion of the script: server=$1 filesystem1=$2 # dsh -w $1 'mkcondition -c "/var space used" -s "Name == \"$2\"" -e "PercentTotUsed > 90" -d "An event will be generated... (7 Replies)
Discussion started by: gravy26
7 Replies
Login or Register to Ask a Question