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
gnu sed replace space with new line xserg Shell Programming and Scripting 1 03-15-2009 03:31 PM
Injecting the Common into Security iBot IT Security RSS 0 02-23-2009 04:40 AM
Multi-line Substitution Gone Awry - perl EmperorNorton Shell Programming and Scripting 7 05-04-2008 11:17 PM
How to use sed substitution using a $variable for a line containing a word Sangal-Arun Shell Programming and Scripting 4 08-07-2007 08:09 PM
Preserving space during command substitution Sabari Nath S UNIX for Dummies Questions & Answers 1 10-04-2005 10:16 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 05-13-2009
ProGrammar ProGrammar is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 13
injecting new line in sed substitution (hold space)

Morning, people!

I'd like to call upon your expertise again, this time for a sed endeavor.

I've already searched around the forums, didn't find anything that helped yet.

background: Solaris 9.x, it's a closed system and there are restrictions to what is portable to it. So let's assume I can't just download an updated GNU/POSIX utility.

Alright, so I've been reading some literature on Sed and I'm under the impression that it is somehow possible to embed/inject a newline in the hold space (the string replacing a pattern).

the intent was to double space some reports that we produce on weekly basis for a more eye-friendly format.

So we have a line as follows;
Group User ID Day Week End Reports Compl Hours Logged
analysis azzame Week 25APR09 13 26.0 42.7
analysis campbels Week 25APR09 26 51.2 48.2

basically, I was trying to double space lines conforming to the above format. NOTE** there are spaces in front of the lines for formatting in the actual file

so I tried a sed edit like this:

# sed 's/^ *analysis.*[0-9]$/&\
/' wkending25APR09.txt


inspiration for this comes from the following

replace > with new line character
at the bottom of this post, it appears as though embedding a newline is possible.


also, the following excerpt from the following link:

sed

"A line can be split by substituting a <newline> into it. The application shall escape the <newline> in the replacement by preceding it by a backslash. A substitution shall be considered to have been performed even if the replacement string is identical to the string that it replaces. Any backslash used to alter the default meaning of a subsequent character shall be discarded from the BRE or the replacement before evaluating the BRE or using the replacement."


Let me know your thoughts, i.e. if I'm chasing a ghost any alternatives would be greatly appreciated, I came across something like gsub function in awk?? I guess that might make it possible, however if it's possible in sed I would prefer that method purely to satisfy my knowledge curiosity.

thanks, y'all!!
ProGrammar
 

Bookmarks

Tags
sed newline substitution pattern embed

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 02:25 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