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
A Different Kind of DoS Attack iBot IT Security RSS 0 09-17-2008 11:30 AM
Kind of knapsack problem ngungo Shell Programming and Scripting 3 11-08-2007 09:35 AM
Kind of weird question Cyberaxe UNIX for Dummies Questions & Answers 2 07-26-2005 06:19 PM
what kind of UNIX hiei UNIX for Dummies Questions & Answers 2 04-12-2004 08:15 PM
Some kind of message command sanjit UNIX for Dummies Questions & Answers 3 12-14-2000 10:45 PM

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 03-10-2009
solaix14 solaix14 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 48
sed help,,kind of urgent!!

Hello All,
My problem is:
I want to replace a line from a file with sed. The first word in that line is always the same in every server. The second line is server model, which of course will vary from platform to platform and I need to leave that word as it is. After the second word, I need to add two words at the end of that line.
example:
serverName Sun-Fire 200 (this is by default)
lets say if the server model is V480, then my output should be:
serverName V480 (test server) (comment

thanks in advance guys!!
  #2 (permalink)  
Old 03-10-2009
ShawnMilo ShawnMilo is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 252
Your description is a little confusing. Do you need to alter the second word, the second line, or the second word on the second line?

In any case, you can do this very simply with a Perl one-liner using the $. variable (which is the current line number) and a regular expression. Please post sample input and sample output from that input if you'd like me to give you the one-liner. That is, if you're open to a Perl solution.
  #3 (permalink)  
Old 03-10-2009
solaix14 solaix14 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 48
May be I will stick to korn shell for the time being.
Here is my simple question,
original content of a particular line in a file:
sysdescr Sun SNMP Agent, Sun-Fire-T2000
I need to modify the above line with:
sysdescr Sun SNMP Agent, Sun-Fire-T2000 - abcd - wxyz
All I want is add (- abcd - wxyz) at the end of this line in a file using sed.

thanks
  #4 (permalink)  
Old 03-10-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,374

Replace PATTERN with the selection criterion for the line.


Code:
sed '/PATTERN/ s/$/- abcd - wxyz/'

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 03:58 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