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
Asterisk on IPCop Asterisk 1.4.23.2 for IPCop 1.4.21 (Default branch) iBot Software Releases - RSS News 0 03-13-2009 06:40 AM
Asterisk on IPCop Asterisk 1.4.21.2 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 07-23-2008 10:20 PM
Asterisk on IPCop Asterisk 1.4.21.1 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 07-08-2008 06:30 PM
Asterisk on IPCop Asterisk 1.4.19.2 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 05-14-2008 07:20 AM
Asterisk on IPCop Asterisk 1.4.19.1 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 04-25-2008 04:10 PM

Reply
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 06-12-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
problem in replacing asterisk in sed

Hi all,

Sed is the one which always trobules me

here is my input :

Code:
 
*** it industry need to be evolved *** in the world and hope so *** to be dream
the output i am expecting is :
Code:
 
*** it industry need to be evolved
*** in the world and hope so 
*** to be dream
here is what i have tried

Code:
TESTING>sed '/ \*\*\* / i\
>
> ' ravi_test.txt
here one line is inserted before the first "***" ( ofcourse it does not follwed spaces as specified in the condition.

One more doubt : when using "tr" to replace the "\n" with " " , further i can't use this output in a filter to sed as sed expects "\n" at the end to consider it as a line ?.. any clue on how to use "tr" in this case( have to retain the last "\n")

thanks and regards
Panyam
  #2 (permalink)  
Old 06-12-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
Something like this?

Code:
sed 's/ \*\*\*/\
\*\*\*/g'
Regards
  #3 (permalink)  
Old 06-12-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,531
if you have Python
Code:
#!/usr/bin/env python
for line in open("file"):
    line=line.strip().split("***")
    for i in line:
        if i!="" : print "***"+i
output
Code:
# ./test.py
*** it industry need to be evolved
*** in the world and hope so
*** to be dream
  #4 (permalink)  
Old 06-12-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
With awk:

Code:
awk '{gsub(" \*\*\*","\n***")}1'
Regards
  #5 (permalink)  
Old 06-12-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
Thanks Franklin and ghostdog74. It's worked fine.
Reply

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