Author:
erics , July 14th, 2021
Solution: “Double Quote” your variables!
shell > myvar = "abc
def
ghi"
shell > echo $ myvar
abc def ghi
shell > echo "$myvar"
abc
def
ghi
See Also: https://stackoverflow.com/questions/22101778/how-to-preserve-line-breaks-when-storing-command-output-to-a-variable
Categories: How-To's , Technology Tags: Capture , Command , Command Output , howto , Keep , line break , Line Breaks , Preserve , Store , Storing , tips , Variable
| No comments
Author:
erics , May 14th, 2020
Recently, I had a list of command-line options in a table, and my browser was automatically inserting a line-break in-between the hyphen and the option character.
< td >
& lt ; code class = "option" & gt ; -- help , - h & lt ; / code & gt ;
< / td >
To prevent this, I simply added a little CSS:
<style>
code.option
{
white-space : nowrap ;
}
</style>
NOTE: Never use the
HTML directive – it is obsolete!
Categories: How-To's , Technology Tags: break , howto , line break , nobr , Prevent , tips
| No comments
Author:
erics , April 16th, 2012
yourUpdatedVar = yourOriginalVar . replace ( / \ n / g , '<br />' ) ;
Categories: How-To's , Technology Tags: howto , javascript , line break , Newline , Replace , Search and Replace , tips
| No comments
Author:
erics , January 11th, 2012
You must use all three lines together for it to work…YMMV:
$ escaped = str_replace ( chr ( 10 ) , '\n' , $ original_value ) ;
$ escaped = str_replace ( chr ( 13 ) , '\r' , $ escaped ) ;
$ escaped = preg_replace ( "/(\r?\n)/" , "\n" , $ escaped ) ;
Categories: How-To's , Technology Tags: Backslash , break , carriage return , control-m , Escape , javascript , JS , line break , Newline , php , Return
| No comments
Author:
erics , September 29th, 2009
To convert DOS line breaks ( ^ M ) to UNIX in VIM :
: % s / ^ M / \ r / g
- OR -
: set fileformat = unix
Categories: How-To's , Technology Tags: convert , dos , line break , linebreak , unix , vim
| No comments