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
TO know whether file is updating or not raj333 Shell Programming and Scripting 2 11-05-2007 05:29 PM
Updating file in loop braindrain Shell Programming and Scripting 4 06-20-2007 02:37 PM
Why my sar is not updating the output file. skneeli UNIX for Advanced & Expert Users 1 11-12-2006 08:29 PM
Updating a File in a Zip Archive dbridle AIX 6 09-27-2006 04:29 PM
sending and updating a file over network bhakti High Level Programming 1 09-21-2005 03:10 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-24-2008
bisla.yogender bisla.yogender is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
Exclamation Sed Help in Updating something only in one particular line.

Hi,

The scenerio is that I want to replace a text in one particular line of a file. But when I am using the sed it's replacing all the occurences of that text.

Like the file is:

>cat test
DNGGF10 :None :Test
DNGGF11 :ABC :Test1
DNGGF12 :None :Test2
DNGGF13 :None : Test3


I have written the following code for this:-
>cat script
name=$1

sed "s/`grep DNGGF10 test|cut -d ':' -f2`/$1/" test >test.chk



But while executing the code as ./script yogi then I am getting O/p in test.chk as:

>cat test.chk
DNGGF10 :Yogi:Test
DNGGF11 :ABC :Test1
DNGGF12 :yogi:Test2
DNGGF13 :Yogi: Test3


But i want to replce second field only for that line which contains DNGGF1O i.e the 1st line.Also space total sapce in second field should also not get altered.

Kindly shed some light on it.

Thanks-
Yogi

Last edited by bisla.yogender; 03-24-2008 at 09:27 AM..
 

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 12:16 PM.


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