Multi-Graphics wrote:

> how can i count the numbers of lines text of a log file
> and how do i show the number
> and how can i print for example line 5 to 15
>
> thanks

In [U,Li]n[i,u]x type this, if you want to read lines 22 through 33:
     more -22 +11 /my_source_path/my_source_file
Add
      > /my_target_path/my_target_file
if you want it to be written to a file.

Type
   tail -n -200  source  > target
, if you want to copy the last 200 lines to a target file.

Read in Linux/Unix about
     less, more, cat, tail ;
maybe you find line counting.

Put this very useful little script as   er.pl   into your cgi-bin folder to read the 
last 36 lines of your site's error report; invoke it as
   http://my-own-site.com/cgi-bin/er.pl
(correct the error_log path, and translate the text to your favorite language))

#!/usr/bin/perl
##############################################
#   Fehlerbericht.pl          soll die letzten 36 Fehlermeldungen zeigen
##############################################
print "content-type: text/html\n\n";
print "Hallo Kinnings!!  Die jüngsten 36 Fehlermeldungen lauten (frisch ist 
oben):<br>";
print "\n<br><font color='#AA0000'>";
@Zeilen = reverse `tail -n -36 /var/log/httpd/logs/error_log`;
for (@Zeilen)   {
  s,(^.*\] )(.*\:),$1<b>$2</b>,;
  s,(\[client.*?]),<font color=\"\#006600\">$1<\/font>,;
  s,(\[.*?]),<font color=\"\#006600\">$1<\/font>,;
  if (++$i<10)   {   print "&nbsp;&nbsp;"   }
  print "(", $i, ")", " $_<br>";   }

print "</font>\n<br>Und tsch&uuml;&szlig;!!";

__END__


Reply via email to