The UNIX and Linux Forums  

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
Unix shell script to parse the contents of comma-separated file KrishnaSaran Shell Programming and Scripting 11 06-20-2008 05:43 AM
Help shell script to loop through files update ctl file to be sql loaded dba_nh Shell Programming and Scripting 1 04-15-2008 08:00 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 03:06 AM
search for the contents in many file and print that file using shell script cdfd123 Shell Programming and Scripting 3 10-07-2007 10:17 PM
How to update the contents in a file conditionally? rajus19 Shell Programming and Scripting 5 10-14-2005 03:20 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
update file contents using shell script

Hi,

I am having a file which contains as below

Names(aaaa
,bbbb
,cccc
,dddd)

now i want the file to be updated with new value 'eeee' as below

Names(aaaa
,bbbb
,cccc
,dddd
,eeee)

Is there a way to script this ?

Thanks,
drams
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-08-2008
Technorati Master
 

Join Date: Mar 2005
Location: k-tier distributed caching
Posts: 2,803
Code:
sed 's/\)\
,eeee\)/' filename
Reply With Quote
  #3 (permalink)  
Old 10-08-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
Thanks for the reply madhan, but i am getting function cannot be parsed error.
Reply With Quote
  #4 (permalink)  
Old 10-09-2008
Technorati Master
 

Join Date: Mar 2005
Location: k-tier distributed caching
Posts: 2,803
Quote:
Originally Posted by drams View Post
Thanks for the reply madhan, but i am getting function cannot be parsed error.
Sorry for the wrong post
this should work

Code:
sed 's/)/\
\,eeee)/' filename
Reply With Quote
  #5 (permalink)  
Old 10-09-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
Thanks a lot!!! It worked..
Reply With Quote
  #6 (permalink)  
Old 10-09-2008
Registered User
 

Join Date: Oct 2008
Posts: 4
what if i am having one more field in the file like

Names(aaaa
,bbbb
,cccc)
count(3)

and i want to update 'eeee' to Names only in file and count to 4 like

Names(aaaa
,bbbb
,cccc
,eeee)
count(4)

Can i do that with script?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 07:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66