Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to redirect output without escape sequences to a file



On May 16,  1:03pm, Thorsten Kampe wrote:
}
} >     ... 2>>(col > trace.log) >&2
} 
} ...and somehow not working (form me). I still got (stripped) color stuff 
} in the output file ("1m33m-0m39m service:directory-agent" for instance).

Hmm, must depend on what "col" is able to determine are escape sequences.
 
} "| sed 's/\x1b\[[0-9]\{1,2\}m//g'" worked for me.
} 
} How would the command line look like if wanted to pipe stdout and stderr 
} to sed, and then redirect both to trace.log?

    { ... } |& sed 's/\x1b\[[0-9]\{1,2\}m//g' > trace.log

where "..." is your original command.  If you want to pipe ONLY stderr
to sed, and then redirect both to trace.log, you'd need something more
along the lines of

    { { ... } 2>>( sed 's/\x1b\[[0-9]\{1,2\}m//g' >&2 ) } >&trace.log

However in that case "sed" runs in the background so you're not
guaranteed to get the same interleaving of output in trace.log as if
you join stdout+stderr together sooner.



Messages sorted by: Reverse Date, Date, Thread, Author