Vincent Rivière <vincent.riviere <at> freesbee.fr> writes: > > > I experienced the same issue with the "cat" command, and unfortunately I > > didn't find any transparent solution > > However a non-transparent hack is to use first a text filter then pipe > its output to the original command. The filter opens the file in > textmode so it gets rid of the CR. Then, as expected, no CR are present > in the pipe. Then normal CRs are added in the resulting file when it is > written on disk. > > The "more" command is a good choice for such a filter, because its pager > functionality is disabled when it writes to a pipe, so it acts as a > simple repeater in textmode: exactly what we need. > > $ more test1 |grep -U -E 'a|b' > test2 > $ xxd test2 > 0000000: 6161 610d 0a62 6262 0d0a aaa..bbb.. > > The result is correct. >
Thanks that could be a solution. Note that I don't have the issue with cat. bash-3.2$ cat test1 > test2 bash-3.2$ xxd test2 0000000: 6161 610d 0a62 6262 0d0a aaa..bbb.. I don't have it with sort used alone : bash-3.2$ /usr/bin/sort test1 > test2 bash-3.2$ xxd test2 0000000: 6161 610d 0a62 6262 0d0a aaa..bbb.. But get it when using sort in a pipe with cat : bash-3.2$ cat test1 | /usr/bin/sort > test2 bash-3.2$ xxd test2 0000000: 6161 610d 0d0a 6262 620d 0d0a aaa...bbb... But using more instead of cat solves the issue : bash-3.2$ more test1 | /usr/bin/sort > test2 bash-3.2$ xxd test2 0000000: 6161 610d 0a62 6262 0d0a aaa..bbb.. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple