[SOLVED] sed: substitute "\n + multiple spaces" to "§"

Hi, i'm trying to achieve something like that:
input:
system:capture_1
system:capture_2
system:playback_1
MPlayer [6922]:out_0
MPlayer [6923]:out_0
system:playback_2
MPlayer [6922]:out_1
MPlayer [6923]:out_1
system:playback_3
system:playback_4
system:playback_5
system:playback_6
system:playback_7
system:playback_8
Output:
system:capture_1
system:capture_2
system:playback_1 § MPlayer [6922]:out_0 § MPlayer [6923]:out_0
system:playback_2 § MPlayer [6922]:out_1 § MPlayer [6923]:out_1
system:playback_3
system:playback_4
system:playback_5
system:playback_6
system:playback_7
system:playback_8
Which turns out to just substitute "\n + multiple spaces" to "§" , but in sed dealing with carriage returns seems not trivial.
help, please?
-EDIT
This seems to work:
cat something | sed ':a;N;$!ba;s/\n / § /g;s/ //g'
Copy Paste fU!
Last edited by kokoko3k (2013-10-15 12:12:05)

sed 's:§:\n   :g' doesn't work for you?
$ cat file
system:capture_1
system:capture_2
system:playback_1 § MPlayer [6922]:out_0 § MPlayer [6923]:out_0
system:playback_2 § MPlayer [6922]:out_1 § MPlayer [6923]:out_1
system:playback_3
system:playback_4
system:playback_5
system:playback_6
system:playback_7
system:playback_8
$ cat file | sed 's:§:\n :g'
system:capture_1
system:capture_2
system:playback_1
MPlayer [6922]:out_0
MPlayer [6923]:out_0
system:playback_2
MPlayer [6922]:out_1
MPlayer [6923]:out_1
system:playback_3
system:playback_4
system:playback_5
system:playback_6
system:playback_7
system:playback_8

Similar Messages

  • Accommodation of multiple space characters without using nbsp - request

    I have dot matrix printer and i want to generate a report using character position and line position.
    For example a line can accommodate 80 chacters and in a page generally accoomdates 72 lines.
    I need to display column value padded with space characters and concatenate with other column and can generate 80 character data set.
    For example name column has varchar2(50) and date_of_birth as date and pay number(10,2)
    I just concatenated as rpad(name,50,' ')||to_char(date_of_birth,'dd-mm-yyyy')||lpad(pay,20,' ') so that all the 80 characters are filled with some characters.
    'dr.s.raghu 01-01-2001 123.45' In between quotes 80 characters are placed including space characters. But while using report and print multiple spaces are getting shrinked as single space character and displays as 'dr.s.raghu 01-01-2001 123.45' If i use nbsp as padded characters, the lettes are getting displayed as nbsp but while on page printing it displayed as space characters.
    I want to accommodate multiple characters of space characters in screen display and as well as in printer image. How to achieve it?
    yours
    dr.s.raghunathan

    dear Piotr
    have seen the example you have shown. I am confident that can be achieved by defining column width and height and example used only three columns. Whereas now i edited my requirement with code tags. Within the column value itself i need multiple spaces between word. Why even in this forum message box unless i use code tag, i am unable to display multiple space characters between any two words. Infact, i am very happy someone also has having the sampe problem and definitely solution will be achieved through some gurus.
    yours
    dr.s.raghunathan

  • How can I set up multiple spaces (desktops) on my new MacBook Pro 10.9.5?  I have six set up on my other computer MacBook Pro 10.8.5 but can't find how to do it on this new one.  Would appreciate help on this.  Cheers.

    How can I set up multiple spaces (desktops) on my new MacBook Pro 10.9.5?  I have six set up on my other computer MacBook Pro 10.8.5 but can't find how to do it on this new one.  Would appreciate help on this.  Cheers.

    It's not completely obvious. What you have to do in Spaces is to position your cursor to the upper right of the screen, after which faint + (plus) sign appears in that area. Click that, upon which another Desktop will appear.
    The + may be difficult or impossible to see with some desktop backgrounds (black, for instance):

  • Replace multiple space characters with a single space

    Hi,
    Oracle 11g R2.
    Looking for a way to replace multiple space characters in a row with a single space. For example, the text "abc abc" should look like "abc abc". I tried toying with replace, but it only works for the case of 2 spaces. Need a solution for the cases where there could be 2 or more spaces.
    select replace(column1, chr(32)||chr(32), chr(32)) from tablea

    Hi,
    If you had to do this without regular expressions, you could use:
    SELECT  REPLACE ( REPLACE ( REPLACE (str, ' ', '~ ')
                     , ' ~'
              , '~ '
              )     AS new_str
    FROM    table_x;assuming there is some sub-string (I used '~' above) that never occurs right next to a space.
    However, unless you're uisng Oracle 9 (or earlier, which you're not doing) you don't have to do this without regular expressions. As you can see, the way Solomon showed is much simpler.

  • Replacing multiple spaces with a single space

    Hi friends,
    I have a string. It can have zero/one/multiple spaces. I want to make the multiple spaces to single space.
    Here are the cases:
    1. ' a b c d efg h' should be changed to 'a b c d e f g h'
    2. ' a b c d e f g h ' should be changed to 'a b c d e f g h'
    3. 'a b c d e f g h' should not be changed
    4. 'abcdefgh' should not be changed
    Both REPLACE and TRANSLATE do not help. I don't want to go for LOOP logic. Please help me to get it in SQL query.
    Thanks in advance!

    Hi,
    964559 wrote:
    Hi friends,
    I have a string. It can have zero/one/multiple spaces. I want to make the multiple spaces to single space.
    Here are the cases:
    1. ' a b c d efg h' should be changed to 'a b c d e f g h'One solution is to post your string on this site, and then copy it back again. (See below for a more serious solution .)
    This site is doing exactly what you want the function to do: it replaces multiple consecutive spaces with a single space. As a result, it's hard to see what you mean.
    To preserve spacing on this site, type these 6 characters
    \(small letters only, inside curly brackets) before and after each section where you want spacing preserved.
    2. ' a b c d e f g h ' should be changed to 'a b c d e f g h'
    3. 'a b c d e f g h' should not be changed
    4. 'abcdefgh' should not be changed
    Both REPLACE and TRANSLATE do not help. I don't want to go for LOOP logic. Please help me to get it in SQL query.
    Thanks in advance!Regular expressions make this easy:SELECT TRIM ( REGEXP_REPLACE ( str
    , ' +'
    ) AS compressed_str
    FROM table_x;
    You can use nested REPLACE calls to get the same results, but it's messy.
    Edited by: Frank Kulash on Feb 5, 2013 10:18 AM
    Added TRIM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Getting rid of Multiple Spaces in Code View (after Copying/Pasting)

    Hello,
    I'm trying to find a way to get rid of multiple spaces between words in Dreamweaver CS3's code view.
    Oftentimes, when I copy/paste text from elsewhere (e-mail, website, etc), the Dreamweaver code shows up with multiple spaces. Normally, that wouldn't be problem -- except that my blog's auto-tag plug-in doesn't detect selected phrases when there are multiple spaces between words, e.g., it'll detect "Swiss Alps" in a post but not "Swiss  Alps" (notice the extra space between words in the second phrase).
    If at all possible, I'd like to be able to keep Dreamweaver's text formatting option when I copy and paste, as that means I don't need to manually put words in bold/italics.So, is there a way to keep that option while getting rid of all the extra spacing between words?
    By the way, I'm familiar with Wordpress CSS, but not with Dreamweaver CSS. Not sure if there's any difference.
    Any assistance would be much appreciated.

    I make it a point to never paste formatted text into HTML pages.  Formatted text from MS Office usually contains a variety of junk you don't want and I don't have that much faith in MS Word code removal tools.
    Bold and Italics from Word or Outlook should be changed to current HTML tags of <strong> for bold and <em> or emphasis for italics anyway.  Also see Logical Tags here:
    http://www.htmlcodetutorial.com/logical.html
    Find and replace is good for removing whitespace if you know how to do it correctly. Make backup copies just in case things go wrong.  http://www.tjkdesign.com/articles/whitespace.asp
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb

  • Showing a window in multiple Spaces

    When I use the equivalent of Spaces in Ubuntu, I can pin a window to the screen so that it appears in multiple Spaces. Can I do this in OS X?

    in spaces preference you can assign an application to "every space". this will make every window of this application appear in every space. you can not do it with just one window though.

  • Spaces confusing safari windows (on multiple spaces using command-tab)

    Wondering if this is happening to anyone else.
    I love spaces but something is messed when using safari windows on multiple spaces. Say I have two safari windows open on two different spaces, after command-tabbing to another app when I try to command-tab back to safari it doesn't always go to my last safari window. That is to say that sometimes it goes to the other safari window, and sometimes it doesn't. It's super unpredictable.
    Give it a try, open two safari windows on two different spaces and the command tab to another app and then command tab back to safari - and repeat... you'll find that it will just randomly go to the other window, and then back etc.
    Can't think of anything more annoying in spaces... that's got to be a bug.
    Anyways, let me know if it's happening to you.
    Jay.

    same issue. i have multiple safari windows with multiple tabs on multiple spaces. let's say one space is a rails space; so it has some terminals, safaris, firefoxes, all perhaps with 2 or more tabs. command-tab does not necessarily go back to the window of the app i was just in. whether it's safari or firefox or whatever. this is horribly un-intuitive. come on apple. that's like your thing, right?

  • Multiple Spaces between words in Java

    Hi All
    String s1 = "boy";
    String s2 = "girl";
    String s = s1 + "multiple spaces through keyboard spacebar writing this because when this is posted it will not be visible in the browser" + s2;
    system.out.println(s);
    I need to have multiple spaces between s1 and s2 and need to be shown in the browser(IE) in java.
    If it is a html code, I found we can use <pre> tag,  
    Thanks

    JoachimSauer wrote:
    JoachimSauer wrote:
    commonly written as " "Sorry, the forum software ate what I wrote here. Actually it is written as "& nbsp;" (but without the space, that I needed to add to keep the forum software from butchering it again).You can display a "raw" entity by escaping the ampersand: &#38;#38;nbsp; I use &#38;#38; instead of &#38;amp; because &#38;amp; doesn't work inside CODE blocks, and &#38;#38; does.
    Of course, all this only applies until the next site upgrade, when they break half the existing features in the process of adding a bunch of new features that nobody wanted. :P

  • Replace multiple spaces

    Hi dear experts,
    I need a function/procedure that replaces multiple spaces by one space.
    (This is because of an Application Express representation of strings in a report).
    (I have to replace ' ' by '_' in this post just because of the same phenomenon).
    Strings like "This___is_an_________example"
    should become " This_is_an__example".
    I need something like:
    create or replace function remove_multispaces(text_in in varchar2) return varchar2 is
    begin
    while instr(text_in,'__') >0 /* two blanks */
    loop
    execute immediate replace (text_in,'__','_'); /*replace 2 blanks by 1 */
    end loop;
    return (text_in);
    end remove_multispaces;
    But this is definitely not working.
    Thank you for your help,
    Hergen.

    SQL> ed
    Wrote file afiedt.buf
    1 create or replace function replace_multispaces(in_str varchar2) return varchar2 is
    2 out_str varchar2(100):=in_str;
    3 begin
    4 while(instr(out_str,'__')>0) loop
    5 out_str:=replace(out_str,'__','_');
    6 end loop;
    7 return(out_str);
    8 exception
    9 when others then
    10 dbms_output.put_line(sqlerrm);
    11* end;
    SQL> /
    Function created.
    SQL> select replace_multispaces('This___is_an_________example') from dual
    2 ;
    REPLACE_MULTISPACES('THIS___IS_AN_________EXAMPLE')
    This_is_an_example
    SQL>

  • Replacing multiple spaces with another character

    i need to replace multiple spaces with another char in a string
    my code is
    Dim text as String="a bit much             a little much" Dim arr As String() = text.Split({" "c}, StringSplitOptions.RemoveEmptyEntries)Dim newtext As String = String.Join(" ", arr)            MsgBox(newtext)           
     it returns to "a bit much  a little much "
    But i want to replace only long spaces with "="  as  "a bit much =a little much"
    How can i do that?

    This version uses two spaces to split the string and then trims any additional single spaces. It returns "a bit much = a little much".
    Dim text As String = "a bit much a little much "
    Dim parts() As String = text.Split({" "}, StringSplitOptions.RemoveEmptyEntries)
    Dim newText As String
    If parts.Length = 2 Then
    newText = parts(0).Trim & " = " & parts(1).Trim
    End If

  • Switching Multiple Spaces Simultaneously

    Hello,
    I am looking for a way to switch multiple spaces simultaneously (preferably with a gesture) with the new Mavericks space per monitor setup.  I know I can revert back to the previous way spaces worked, but would rather find a way to do a hybrid of the two.
    Most of the time being able to switch each monitor individually is fine. In fact it might be preferable, but if I have any of my multiple monitor programs (After Effects, Premier, Lightroom, etc.) open, this behavior becomes cumbersome, and it would be great if I could switch all three of my monitors at once without having to change the setting log out and then back in.
    Anyone know of an app that would allow for setting one gesture to switch the space of the curent monitor and a seperate one to switch all of the spaces?
    Thanks!
    Patrick

    JoachimSauer wrote:
    JoachimSauer wrote:
    commonly written as " "Sorry, the forum software ate what I wrote here. Actually it is written as "& nbsp;" (but without the space, that I needed to add to keep the forum software from butchering it again).You can display a "raw" entity by escaping the ampersand: &#38;#38;nbsp; I use &#38;#38; instead of &#38;amp; because &#38;amp; doesn't work inside CODE blocks, and &#38;#38; does.
    Of course, all this only applies until the next site upgrade, when they break half the existing features in the process of adding a bunch of new features that nobody wanted. :P

  • Storage Question: My macbook air says I have 35gb worth of movies. I only have 1 movie that I'm aware of! How do I solve whats eating all this space?

    My macbook air says I have 35gb worth of movies. I only have 1 movie that I'm aware of! How do I solve whats eating all this space?
    Please help me!!

        Lion  OS X  10.7 Lion / 10.8 Mountain Lion
        http://support.apple.com/kb/PH3782
        For more on this and very helpful tips:
        http://pondini.org/OSX/DiskSpace.html
        http://pondini.org/OSX/LionStorage.html

  • [SOLVED] sed works in arch, but in os x it's different?

    Hello, I have a quick question about sed and using newlines.
    Say I have a file with one line in it like so:
    va.artofwarcentral.com
    I want to split each of the parts separated by periods into new lines.
    I used sed to do this:
    sed 's/\./\n/g' filename
    and it works without incident.  The output is this:
    va
    artofwarcentral
    com
    However, when I try this on OS X I get this unexpected output:
    vanartofwarcentralncom
    Am I mistaken in thinking that the newline character in OS X is \n ?  I have tried several different escape characters, and they all give me back the same thing...it ignores the escape and just prints the character.
    So, I guess my question is this:  am I doing something wrong or is this something that OS X is doing retardedly?  I know this might not be the best place to ask this since it's really more of an OS X question, but hopefully someone knows the answer.  I'm new to sed and regular expressions and all that jazz, so odds are I'm just doing something wrong.  Any help is appreciated.
    Last edited by jordanmthomas (2007-11-18 12:35:56)

    jordanmthomas wrote:
    Heh, sorry for posting it here.
    Anyway, to get around the issue I have just separated it with spaces and used awk to get each word out, which seems to work on Arch and OS X.
    So problem solved anyway now.
    If you are still interested, there is some relevant information here (see Hal Itosis' post(s) especially):
    http://forums.macosxhints.com/archive/i … 62778.html
    Summary:
    - update or change your version of sed
    - use Perl
    - use currently installed sed with some of the tricks supplied by Hal Itosis
    - or stick with what you already did.

  • How do I add multiple spaces?

    I am using Dreamweaver 11.0 / CS5 on a Windows 7 PC.
    In the preview editor I am trying to add a space in front of some text. Hitting the spacebar does NOTHING.
    It should be adding a   or at least doing SOMETHING.
    Help!

    Two ways to do it:
    CTRL+SHIFT+SPACEBAR
    or
    Go to your Dreamweaver preferences Edit->Preferences and under the general category check "Allow Multiple Consecutive Spaces"
    Brad Lawryk
    Adobe Community Professional: Dreamweaver
    Northern British Columbia Adobe Usergroup: Manager
    Thompson Rivers University: Dreamweaver Instructor
    My Adobe Blog: http://blog.lawryk.com

Maybe you are looking for

  • Com.sap.sql.log.OpenSQLException: table or view not exists

    Hi!. I'm developing a Portal Component over NW EP 2004s (7.0) which access to SQL Server database. I have created three tables on the system db (EPD). Connection is Ok, over datasource object, but i can't make a SELECT operation to my new tables. Hov

  • Value field in Shipper's Letter of Instructions

    Hi All, The Shipper's Letter of Instructions form within SED document is not showing up the value. Can any body please point me where to look for or any missing config steps to populate this field? Currently it is just showing '1'. Thanks Sreekar

  • Pack and unpack

    Hi Please do help me.   Data: dmshb(11),             "amount in SEK or EUR           amount_1    LIKE dfkkop-betrw.  " of length 13 and decimal 2 with +/-sign   amount_1 = '   91111111.00-'.   dmshb = amount. the result of this is   dmshb = *111111.0

  • Migrate/Upgrade [SSIS Configurations] table 2005 to SSISDB Catalog in 2012

    Hi Everyone, Our SSIS are still in 2005 and we are using the SSIS Configurations table to store our parameters. Our set-up is based from this link . Now, we are moving to SSIS 2012 and wanted to maximize the SSISDB Catalog.  I just want to know how c

  • Working with Canon 5D MarkII H.264 Footage in Final Cut Studio - 5, Not 6

    I'm new to this whole posting thing, but I'm hoping I can get some help. I'm just now starting to try to edit video footage from my Canon 5D Mark II in Final Cut, but I do not have FCP6, I have FCP5. I'm starting to realize this may be a problem, as