UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old October 21st, 2003, 09:25 PM
kitchiekoo kitchiekoo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 kitchiekoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sed command problem

hi all. pls help.

i am using the sed command to substitute several text patterns in a file. my problem is, i want to replace the pattern with a new line. i cant seem to make \n work. here's an example. the patterns to be replaced with a next line are "abc", "def" and "hij".

input file:
qwertyabcuiop asdfgdefhjkl hijzxcvbnm

output file shoule be like this:
qwerty
uiop asdfg
hjkl
zxcvbnm

thanks.

Reply With Quote
  #2  
Old October 22nd, 2003, 06:19 AM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
To my knowledge, \n doesn't work in sed. But you can spilt lines:

Code:
#!/bin/bash

echo "This is a test sentence" | \
sed -n 's/This is\(.*\)/This is\
\1/p'


=> This is\(.*\)
Searchpatern.

=> This is\
=> \1
Output patern. The \ after is is there for the linebreak, the \1 prints all that was captured with the \(.*\).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > sed command problem


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway