On Thu, Jul 23, 2015 at 03:41:13PM +0200, Hans Ginzel wrote: > Hello! > > Consider, please, this small script > > echo 1 > echo 1>"a b" > echo 2 > echo 2>"c\nd"
Did you intend to write the number "2" to a file, or did you intend to redirect stderr? > Why is there the additional new line between 2 and 3 or 3 and 4 > respectively. Because you are redirecting stderr instead of stdout. echo is writing to stdout, and it has no arguments, so stdout just gets a blank line. You are redirecting stderr to a file named c\nd (that's four characters, one of which is a literal backslash), but nothing is being written to stderr, so the file is 0 bytes long. I believe you probably wanted: echo 2 >$'c\nd' The space after the 2 is extremely significant, and $'...' is how you create strings (filenames, etc.) with control characters in them.