![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|