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
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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2008
drams drams is offline
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
  #2 (permalink)  
Old 10-08-2008
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Code:
sed 's/\)\
,eeee\)/' filename
  #3 (permalink)  
Old 10-08-2008
drams drams is offline
Registered User
  
 

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

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
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
  #5 (permalink)  
Old 10-09-2008
drams drams is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 4
Thanks a lot!!! It worked..
  #6 (permalink)  
Old 10-09-2008
drams drams is offline
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?
Sponsored Links
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 04:56 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