Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmmm... isn't it possible to do this with just the GnuWin32 utilities? Perhaps using "tr"? The whole reason I'm trying to use the GnuWin32 version of grep is to get rid of reliance on cygwin stuff.
Thanks for the idea, though.
Thom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But dos2unix is a GnuWin32 port. It is not dependent on Cygwin. Cygutils is a collection of utilities so called because originally they were intended to be useful for Cygwin. However, most of them, such as dos2unix, can be, and on Gnuwin32 have been, ported to native MS-Windows.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah, yes... I realized that after posting my previous note. So, unix2dos it is. (Though I was really hoping for a grep commandline option to change the output format. Oh, well.)
Thanks again.
Thom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I'm playing devil's advocate here, but shouldn't the output from a native port of grep be CRLF anyway? Why would any tool, intended for processing text files and compiled natively on Woe32, explicitly force stdout to _O_BINARY mode, (which would be required to achieve LF, rather than CRLF output)?
IMO, (which probably doesn't count for much here, since I use the MSYS ports of tools such as grep, and I expect them to force _O_BINARY mode anyway), this could be considered a bug in the GnuWin32 port.
I've (finally) looked into this. It appears that this behavior is by design, so actually it is a feature. Basically grep behaves in this way because it can also grep binary files (this ìs advertised as an option and a possible use of grep), for which conversion to CRLF would be inappropriate. In general, I'm not in favor of changing behavior that is by design; instead one should address the maintainer. The one possibility I see for such a request would be a combination of the -a (--text) option with CRLF conversion, since then the user explicitly requests all files to be viewed as text files, and so all output might be regarded as text output.
In the port of grep-2.5.3, I will for the time being implement this combination of --text and CRLF output, provided no-one objects, beforehand or later.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I need to get the output of the grep command to be in DOS format (using CRLF instead of LF). There's an easy way to do this, right?
Thanks!
WinXP SP2 and Win2K SP5
C:\Program Files\GnuWin32\bin>grep --version
grep (GNU grep) 2.5.1
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Filter grep's output through unix2dos (from CygUtils: http://gnuwin32.sourceforge.net/packages/cygutils.htm)
Hmmm... isn't it possible to do this with just the GnuWin32 utilities? Perhaps using "tr"? The whole reason I'm trying to use the GnuWin32 version of grep is to get rid of reliance on cygwin stuff.
Thanks for the idea, though.
Thom
But dos2unix is a GnuWin32 port. It is not dependent on Cygwin. Cygutils is a collection of utilities so called because originally they were intended to be useful for Cygwin. However, most of them, such as dos2unix, can be, and on Gnuwin32 have been, ported to native MS-Windows.
Ah, yes... I realized that after posting my previous note. So, unix2dos it is. (Though I was really hoping for a grep commandline option to change the output format. Oh, well.)
Thanks again.
Thom
Ok, I'm playing devil's advocate here, but shouldn't the output from a native port of grep be CRLF anyway? Why would any tool, intended for processing text files and compiled natively on Woe32, explicitly force stdout to _O_BINARY mode, (which would be required to achieve LF, rather than CRLF output)?
IMO, (which probably doesn't count for much here, since I use the MSYS ports of tools such as grep, and I expect them to force _O_BINARY mode anyway), this could be considered a bug in the GnuWin32 port.
This said, the
-U' (a.k.a.--binary') option may be helpful in your case; see http://man.linuxquestions.org/?query=grep§ion=0&type=2 for details.Regards,
Keith.
I concur.
I've (finally) looked into this. It appears that this behavior is by design, so actually it is a feature. Basically grep behaves in this way because it can also grep binary files (this ìs advertised as an option and a possible use of grep), for which conversion to CRLF would be inappropriate. In general, I'm not in favor of changing behavior that is by design; instead one should address the maintainer. The one possibility I see for such a request would be a combination of the -a (--text) option with CRLF conversion, since then the user explicitly requests all files to be viewed as text files, and so all output might be regarded as text output.
In the port of grep-2.5.3, I will for the time being implement this combination of --text and CRLF output, provided no-one objects, beforehand or later.