This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: grep: $ in PATTERN doesn't seem to work properly


Koduru, Seshasai wrote:
> Hi,
>
> When $ is used in the PATTERN of grep command, it doesn't seem to
> work properly on my machine.
>
> I have run the following under cygwin.bat shell.
>
> $ cat tmp
> Line 1
> Line 2
>
> Line 3
> Line 4
> Line 5
>
> $ grep '1$' tmp
> (Gives no output. It should give output as
> Line 1)
SNIP

Note that there is a difference depending on how you create the file; I'll
hand over to cygwin-specialists to explain (or ponder on) why it has to be
this way.

I'm running BINARY mounts all over, still I get the behaviour below.

binmode proof:
$ mount | grep 'binmode' | wc -l
     23
$ mount | wc -l
     23

=== a) ===
$ cd			# cd to $HOME
$ cat >tmp
Line 1
Line 2

Line 3
Line 4
Line 5
$POSIX="" - Hannu@P450 ~ bash (P)PID=(852)2340, s=0
$ od -w8 -t x1z tmp
0000000 4c 69 6e 65 20 31 0d 0a  >Line 1..<
0000010 4c 69 6e 65 20 32 0d 0a  >Line 2..<
0000020 0d 0a 4c 69 6e 65 20 33  >..Line 3<
0000030 0d 0a 4c 69 6e 65 20 34  >..Line 4<
0000040 0d 0a 4c 69 6e 65 20 35  >..Line 5<
0000050 0d 0a                    >..<
0000052
$ grep '1$' tmp
$ d2u tmp 				# dos2unix
tmp: done.
$ grep '1$' tmp
Line 1

=== b) ===
$ cd
$ ls -l tmp2
ls: tmp2: No such file or directory
$ for (( i=1 ; i<6 ; i++ )) do echo >>tmp2 "Line $i";done
$ od -w7 -t x1z tmp2
0000000 4c 69 6e 65 20 31 0a  >Line 1.<
0000007 4c 69 6e 65 20 32 0a  >Line 2.<
0000016 4c 69 6e 65 20 33 0a  >Line 3.<
0000025 4c 69 6e 65 20 34 0a  >Line 4.<
0000034 4c 69 6e 65 20 35 0a  >Line 5.<
0000043
$ grep '1$' tmp
Line 1

$ rm tmp tmp2

/Hannu E K Nevalainen, B.Sc. EE Microcomputer systems            --72-->

** mailing list preference; please keep replies on list **

-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]