-1

As the title says, i'm trying to use sed to replace, say,

ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE myserver1 ora.LISTENER_SCAN2.lsnr 1 ONLINE ONLINE myserver2

into:

ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE myserver1
ora.LISTENER_SCAN2.lsnr 1 ONLINE ONLINE myserver2

I've tried using: sed 's/ ora*/\n/g' but to no avail. Help would be greatly appreciated!

ShvartZ
  • 11
  • 2
  • 1
    In any case, it is best to include the period after `ora` in the search pattern; otherwise you will also break at `[space]oracle` and even at `[space]orange`. – mathguy Aug 15 '18 at 16:14

1 Answers1

1

If you need to replace [space]ora. with [newline]ora., do EXACTLY THAT in SED:

's/ ora\./\nora\./g'
mathguy
  • 37,873
  • 5
  • 22
  • 47
  • A few notes: this will introduce a blank line; not every sed can insert a newline by using `\n` in the replacement string. – Benjamin W. Aug 15 '18 at 16:23
  • I've tried this and the output remains with no new lines – ShvartZ Aug 15 '18 at 16:26
  • @ShvartZ - It works on my machine. What version of Linux are you using? In any case, **this** (what Benjamin said) may be your issue; it is not quite the same as what you asked initially. – mathguy Aug 15 '18 at 16:28
  • @BenjaminW. - you said **a few** notes. I only see one. Did you mean to say more? – mathguy Aug 15 '18 at 16:28
  • @mathguy RHEL 5.11 is the server's OS version (yup I know) – ShvartZ Aug 15 '18 at 16:31
  • For the record, `sed --version` on my machine reports `sed (GNU sed) 4.2.2`. I am on Oracle Linux 7.5; in the Oracle world, this is a successor to RHEL. It should be about the same as RHEL 7.5. – mathguy Aug 15 '18 at 16:37
  • Ah, sorry, I did have two at first, then realized that the other one was not valid ;) – Benjamin W. Aug 15 '18 at 17:42
  • Actually, this still are two (introduces blank line, might not work with `\n`). The third one was about shortening by using `&`, but that would have kept the blank. – Benjamin W. Aug 15 '18 at 17:43
  • @BenjaminW. - I missed the "blank" line as part of your original comment. No, on my machine the solution I provided does not introduce a blank line - it only splits the input line into two lines. There are no "blank" lines in the output. – mathguy Aug 15 '18 at 18:42
  • Oh, right, because the `ora` has no leading blank! Time for a coffee... – Benjamin W. Aug 15 '18 at 18:43