The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
VI Substitution problem gravy26 AIX 7 02-13-2008 04:12 PM
Bash: bad substitution problem...pls help! xfouxs UNIX for Dummies Questions & Answers 1 11-23-2007 05:48 PM
ksh substitution solea Shell Programming and Scripting 2 08-09-2004 05:30 AM
bad substitution problem (easy question) champion UNIX for Dummies Questions & Answers 10 07-01-2002 11:16 PM
Substitution using sed Ohji UNIX for Dummies Questions & Answers 3 08-17-2001 11:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-03-2007
er_ashu er_ashu is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 50
Exclamation 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 (permalink)  
Old 04-03-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
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 07:22 AM..
  #3 (permalink)  
Old 04-03-2007
er_ashu er_ashu is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 50
Thanks a lot.
  #4 (permalink)  
Old 04-03-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
in perl:
Code:
$ perl -pi -e 's/29-MAR-2007(\s+)$/02-APR-2007\1/' filename
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0