Strange grep behavior - fixed

Strange grep behavior - fixed

Post by Steve Fau » Wed, 05 May 1993 05:19:49



I would like to thank Evan Manning who solved my grep/filename print
problem.  The reason why the filename was not being printed when the
string was found in multiple files was caused by embedded carriage
return characters (^M) in the log files.  The ^M character, which
preceded each line in the file, was overwriting the filename part of
the output string from grep.

Thanks again Evan,

-Steve

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~ NeoPath Inc.          Bellevue, Washington USA ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 
 
 

1. Strange grep behavior

Hello,

I am experiencing a strange problem with the grep command on a Sun
(SunOS 4.1.2) and was wondering if someone knows what the cause is
and how to fix it.  When I grep for a fixed string in my .c files
it is found and the filename is printed with the line.  Something
like this:

% grep open *.c
size.c:    if((fh = open(argv[1], O_RDONLY)) == -1) {
tvmstat.c:      proc = popen(cmd,"r");
tvmstat.c:              fprintf(stderr,"popen failed!\n");
xkey.c:     fprintf(stderr, "Blah, can't open display: %s\n", hostname);

When I grep for a string in my log files, which were created with xterm
logging, the string is found and printed, but the filename is NOT.
Again, something like this:

% grep Slide *.log
 Msg ( apConfig ): Image Sequencing and Slide Setup modules initialized.
ascMakeSlideSummaryFile=0
_ascMakeSlideSummaryFile = 0xa14108: value = 0 = 0x0
Slide Dimensions ---
On Slide Dimensions ---
Slide Tilt Maximums ---
4x Slide Setup ---
20x Slide Setup ---
Slide Processing Switches ---
  User Interface           =          Slide Training
  Repeat Slide Analysis    =          No

If I use the -l option it will print the filename, so it does appear that
it knows what file the string came from.  Does anyone know if there's
a problem with grep or am I doing something wrong?

Thanks in advance,

-Steve

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~ NeoPath Inc.          Bellevue, Washington USA ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2. FTP Chroot Prolbem

3. strange grep behavior

4. Creating Dynamic Libraries for DG Aviions under dgux5.4.xx

5. Strange keyboard behavior - no . , / - reboot fixes it!

6. Trouble Installing IBM Firewall 4.1

7. grep sTerm * | grep -v grep ???

8. Lion Crew

9. tail | grep | grep | grep

10. csh/tchs: odd behaviour on prog | grep -q string

11. Strange results with ps, grep, and awk

12. strange grep error

13. grep problems - strange