Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 16th December 2009, 11:26 AM
lynxus Offline
Registered User
 
Join Date: Oct 2006
Posts: 216
linuxfedorafirefox
Using sed to add commas to new lines.

Hi Guys,
I have some data like below:

interface Vlan1
description Management LAN
interface Vlan41
description Somelan
interface Vlan65
description Some other lan.
service-policy input 2Mbps
service-policy output 2Mbps

How can i get sed to look at this txt file and add a comma at the beginning of every new line between the interface lines.

IE:
interface Vlan1
,description Management LAN
interface Vlan41
,description Somelan
interface Vlan65
,description Some other lan.
,service-policy input 2Mbps
,service-policy output 2Mbps


Any ideas?

Thanks
Graham
Reply With Quote
  #2  
Old 16th December 2009, 12:03 PM
distributer Offline
Registered User
 
Join Date: Aug 2009
Location: UK
Posts: 94
windows_xp_2003firefox
I would try to define lines that do not match the "interface" thing.

something like (not sure I am on windows here -.-):
Code:
sed 's/^[^interface]/,/' test.txt
the ^ before the brackets means at the beginning of each line and inside the brackets means does not... hope this helps.

//edit: lol just noticed you were looking for the word "interface"

Last edited by distributer; 16th December 2009 at 12:20 PM.
Reply With Quote
  #3  
Old 16th December 2009, 12:17 PM
ghostdog74 Offline
Registered User
 
Join Date: Sep 2006
Posts: 52
linuxfedorafirefox
the sed command is wrong. please check your output
Code:
$ awk '!/interface/{$0=","$0}1' file
Reply With Quote
Reply

Tags
add, commas, lines, sed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Colorful lines tweak Installation and Live Media 5 23rd July 2009 10:50 PM
bundled dsl lines raymd23 Servers & Networking 0 11th June 2009 09:30 AM
awn has ugly lines on it that came from no where peterbug Using Fedora 0 20th January 2009 07:02 PM
command lines LordRyugen Using Fedora 4 1st December 2004 12:19 AM


Current GMT-time: 18:42 (Saturday, 25-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat