Sponsored Content
Top Forums Shell Programming and Scripting How to divide results into several pages? Post 302342832 by Smiling Dragon on Monday 10th of August 2009 11:50:43 PM
Old 08-11-2009
If you are trying to insert a pagebreak every 50 lines, that's not too hard to do in perl:
Code:
$maxlines=50;
$linenum=0;
while (<STDIN>) {
  $linenum++;
  if ($linenum > $maxlines) {
    $linenum=0;
    print "^L";
  }
  print "$_";
}

(Untested)
You'll need to put an actual page break in there where it has ^L (ie don't copy-paste the ^ and the L characters, use a single control-L character).

Should do the job.

You can also do it using perl's rather nice 'format' option Perl format Primer (1/2)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script needs to divide by 2

i need to divide this count by 2, what variable can i use in my script? 26 hcscprod_cpus_totals /2 = 13 13 hcncprod_cpus_totals /2= 6.5 541 ktazp_cpus_totals /2= 270.5 346 ktazd_cpus_totals /2=173 110 ktazi_cpus_totals /2=55 10 ktazq_cpus_totals /2=5 (2 Replies)
Discussion started by: wereyou
2 Replies

2. Shell Programming and Scripting

divide with awk

Dear, i want to devide the first 4 values from a raw over the next 4 values like the following: $1+$2+$3+$4 / $5+$6+$7+$8 using AWK ....can someone help me? Sanks (1 Reply)
Discussion started by: tontal
1 Replies

3. UNIX for Dummies Questions & Answers

divide issue

Hi, I have a issue dividing 2 values in UNIX a=15 b=100 c = a / b ==> and it is returning 0 instead of 0.15 into variable C. How can i resolve this issue ? please help (1 Reply)
Discussion started by: kotasateesh
1 Replies

4. Shell Programming and Scripting

Can ctag and cscope support recording search results and displaying the history results ?

Hello , When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Discussion started by: 915086731
0 Replies

5. Shell Programming and Scripting

Divide variable

Hi All, here D Prints the bytes value .plz help to convert the variable D value to MB in new variable $E D=`more $C |awk '{print $6;}'` Thanks in Advance.:) (3 Replies)
Discussion started by: netdbaind
3 Replies

6. Shell Programming and Scripting

Divide two variable

F= `expr $E/$S` output test5.sh: line 45: 1296863.27001857757568359375/21997: No such file or directory can any one help me ,i just want to divide the $E/$S and Print o/p in F. (3 Replies)
Discussion started by: netdbaind
3 Replies

7. Shell Programming and Scripting

Divide by zero script

Hi, I've been working on a few scripts and have been getting great info. How, would I include in the below script, how I would let a user know that if they divide a SECOND number by zero, that they would get a divide by zero error? What's the easiest way of working this? Cordially, joe. ... (1 Reply)
Discussion started by: jefferj54
1 Replies

8. UNIX for Dummies Questions & Answers

To divide file

We have large log files, and we need to extract last four hours lines only, Please let us know the command. Thanks, Saurau. (1 Reply)
Discussion started by: saurau
1 Replies

9. What is on Your Mind?

Moved Advanced Stats to Search Results Pages

FYI, today I moved the "Advanced Stats" page from the forum home page to the search results pages. This means that at the top of the search results like "Today's Post" and "New Posts" and keyword searches, the stats will appear at the top of that page instead of the home page. The reason of... (3 Replies)
Discussion started by: Neo
3 Replies

10. Shell Programming and Scripting

I want to add a variable for the results from the formula of one variable and results of another var

Good morning all, This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
Discussion started by: Ibrahim A
2 Replies
ERROR(3)						     Linux Programmer's Manual							  ERROR(3)

NAME
error, error_at_line, error_message_count, error_on_per_line, error_print_progname - glibc error reporting functions SYNOPSIS
#include <error.h> void error(int status, int errnum, const char *format, ...); void error_at_line(int status, int errnum, const char *filename, unsigned int linenum, const char *format, ...); extern unsigned int error_message_count; extern int error_one_per_line; extern void (* error_print_progname) (void); DESCRIPTION
error() is a general error reporting function. It flushes stdout, and then outputs to stderr the program name, a colon and a space, the message specified by the printf(3)-style format string format, and, if errnum is nonzero, a second colon and a space followed by the string given by perror(errnum). Any arguments required for format should follow format in the argument list. The output is terminated by a new- line character. The program name printed by error() is the value of the global variable program_invocation_name(3). program_invocation_name initially has the same value as main()'s argv[0]. The value of this variable can be modified to change the output of error(). If status has a nonzero value, then error() calls exit(3) to terminate the program using the given value as the exit status. The error_at_line() function is exactly the same as error(), except for the addition of the arguments filename and linenum. The output produced is as for error(), except that after the program name are written: a colon, the value of filename, a colon, and the value of linenum. The preprocessor values __LINE__ and __FILE__ may be useful when calling error_at_line(), but other values can also be used. For example, these arguments could refer to a location in an input file. If the global variable error_one_per_line is set nonzero, a sequence of error_at_line() calls with the same value of filename and linenum will result in only one message (the first) being output. The global variable error_message_count counts the number of messages that have been output by error() and error_at_line(). If the global variable error_print_progname is assigned the address of a function (i.e., is not NULL), then that function is called instead of prefixing the message with the program name and colon. The function should print a suitable string to stderr. CONFORMING TO
These functions and variables are GNU extensions, and should not be used in programs intended to be portable. SEE ALSO
err(3), errno(3), exit(3), perror(3), program_invocation_name(3), strerror(3) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2006-04-25 ERROR(3)
All times are GMT -4. The time now is 01:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy