Tag Info

New answers tagged

0

You are getting a newline in the output. The problem is that this is a Unix newline, which Windows doesn't recognize. Unix encodes newlines as the LF (line feed) character, whereas Windows newlines consist of the two-character sequence CRLF (carriage return, line feed). To view the output correctly under Windows, use just about anything other than the type ...


0

If you don't to modify files, just print differences, then one option is to simple ignore all white spaces with -w option, so that you can use your braces normally diff -wy file-{a,b} | less Of course this method only works if there are no other important changes in whitespace. If your intention is to repair the files then I would recommend to use ...


3

It doesn't matter in the least if your function prints a newline or not. Command substitution will remove them if there are any present. Bash performs the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. (emphasis mine) testfunc() { echo hello; } # a ...


0

IMHO, this might partly have to do with echo but there's another part of the problem taking influence. So the ideal situation would be if your distro did ship a recent GNU version of tr (like in mine), because as you can see below, there is a clear quirk in your syntax and GNU tr complains to show you where you have to apply the "fix". original: $ ...


3

Neither, cat, tr or head adds a newline character (urandom could, but it's random so I wouldn't trust it). You have to manually insert the new line, with either a printf '\n' at the end of your function, or an echo. BTW, some shells do add it, like zsh, to prevent these kinds of situations.


0

sed always removes the trailing \newline just before populating pattern space, and then appends one before writing out the results of its script. A \newline can be had in pattern-space by various means - but never if it is not the result of an edit. This is important - \newlines in sed's pattern space always reflect a change, and never occur in the input ...


0

Alternatively, you can use a slightly simpler syntax: sed ':a;N;s/\n/,/g;ba' ...just changing sequence order.



Top 50 recent answers are included