Sponsored Content
Top Forums Shell Programming and Scripting Awk: Page number with total number of pages, EG Page 1 of 5 Post 303043230 by MadeInGermany on Wednesday 22nd of January 2020 02:39:33 AM
Old 01-22-2020
I wonder if one should consolidate to one lengthy condition?
Here is my attempt
Code:
awk -F';' '
  FNR!=NR
  /This is the last line of the page/ {
    if (FNR==NR) total++; else printf "Page No:%d of %d\n", ++page, total
  }
' textfile1  textfile1  > textfile12


Last edited by MadeInGermany; 01-22-2020 at 05:27 AM.. Reason: Fixed code logic
 

8 More Discussions You Might Find Interesting

1. News, Links, Events and Announcements

Unix Manual (man-page) pages in HTML

LINK: Unix Manual (man page) pages in HTML http://www.rt.com/man/ : More then 100 Commands found on a Unix system mannual pages can be obtained/refered here. Good Link.. (1 Reply)
Discussion started by: killerserv
1 Replies

2. Shell Programming and Scripting

Perl find page number in a file

Hi i want to ask how can i use perl and find a word in a text file, and also telling that which page doesn't it exist? Eample: have a 10 pages text file, then i need to find 'Hello' in the file, and show that which page is it contain in. Output: Hello contains 8 times in page 1, 3, 4, 7, 10... (9 Replies)
Discussion started by: mingming88
9 Replies

3. Shell Programming and Scripting

How to input a number in a web page and pass to a script?

I am working on an embedded linux router and trying to make a webpage where the user can input a desired number of CPE and have a script update that number on the router. I have a CLI where I can log in and type the following to change that number echo "20">/proc/net/dbrctl/maxcpe which then... (7 Replies)
Discussion started by: BobTheBulldog
7 Replies

4. Emergency UNIX and Linux Support

Grab total page read from webalizer display in html

Hi, I need a way to grab the total combines since inception, total pages read from webalizer on my centos server or any other location (as long as since inception) and display the result live on my website So with each visit it would be increasing, or perhaps live (ajax) not sure But can... (0 Replies)
Discussion started by: lawstudent
0 Replies

5. What is on Your Mind?

Fedora Man Pages Reported Attack Page?

Is firefox complaining to anyone else that this is a Reported Attack Page!? I have used this site a million times and now it feels like complaining. Fedora Manpages: Home (5 Replies)
Discussion started by: cokedude
5 Replies

6. Shell Programming and Scripting

Help with sum total number of record and total number of record problem asking

Input file SFSQW 5192.56 HNRNPK 611.486 QEQW 1202.15 ASDR 568.627 QWET 6382.11 SFSQW 4386.3 HNRNPK 100 SFSQW 500 Desired output file SFSQW 10078.86 3 QWET 6382.11 1 QEQW 1202.15 1 HNRNPK 711.49 2 ASDR 568.63 1 The way I tried: (2 Replies)
Discussion started by: patrick87
2 Replies

7. Shell Programming and Scripting

Splitting of files - Addition of Page Number in the Trailer

Hi, I need your help on the following Scenario : Consider a file has 650 records and I need to split this file into 4 files having a maximum of 200 records in each of them and also for the first splitted file it should get appended with Page 1 as a trailer( Similarly for the second file, Page... (4 Replies)
Discussion started by: Ravichander
4 Replies

8. Shell Programming and Scripting

script for adding page number before page breaks

Hi, If there is an expert that can help: I have many txt files that are produced from pdftotext that include page breaks the page breaks seem to be unix style hex 0C. I want to add page numbers before each page break as in : Page XXXX Regards antman (9 Replies)
Discussion started by: antman
9 Replies
Data::Page(3)						User Contributed Perl Documentation					     Data::Page(3)

NAME
Data::Page - help when paging through sets of results SYNOPSIS
use Data::Page; my $page = Data::Page->new(); $page->total_entries($total_entries); $page->entries_per_page($entries_per_page); $page->current_page($current_page); print " First page: ", $page->first_page, " "; print " Last page: ", $page->last_page, " "; print "First entry on page: ", $page->first, " "; print " Last entry on page: ", $page->last, " "; DESCRIPTION
When searching through large amounts of data, it is often the case that a result set is returned that is larger than we want to display on one page. This results in wanting to page through various pages of data. The maths behind this is unfortunately fiddly, hence this module. The main concept is that you pass in the number of total entries, the number of entries per page, and the current page number. You can then call methods to find out how many pages of information there are, and what number the first and last entries on the current page really are. For example, say we wished to page through the integers from 1 to 100 with 20 entries per page. The first page would consist of 1-20, the second page from 21-40, the third page from 41-60, the fourth page from 61-80 and the fifth page from 81-100. This module would help you work this out. METHODS
new This is the constructor, which takes no arguments. my $page = Data::Page->new(); There is also an old, deprecated constructor, which currently takes two mandatory arguments, the total number of entries and the number of entries per page. It also optionally takes the current page number: my $page = Data::Page->new($total_entries, $entries_per_page, $current_page); total_entries This method get or sets the total number of entries: print "Entries:", $page->total_entries, " "; entries_per_page This method gets or sets the total number of entries per page (which defaults to 10): print "Per page:", $page->entries_per_page, " "; current_page This method gets or sets the current page number (which defaults to 1): print "Page: ", $page->current_page, " "; entries_on_this_page This methods returns the number of entries on the current page: print "There are ", $page->entries_on_this_page, " entries displayed "; first_page This method returns the first page. This is put in for reasons of symmetry with last_page, as it always returns 1: print "Pages range from: ", $page->first_page, " "; last_page This method returns the total number of pages of information: print "Pages range to: ", $page->last_page, " "; first This method returns the number of the first entry on the current page: print "Showing entries from: ", $page->first, " "; last This method returns the number of the last entry on the current page: print "Showing entries to: ", $page->last, " "; previous_page This method returns the previous page number, if one exists. Otherwise it returns undefined: if ($page->previous_page) { print "Previous page number: ", $page->previous_page, " "; } next_page This method returns the next page number, if one exists. Otherwise it returns undefined: if ($page->next_page) { print "Next page number: ", $page->next_page, " "; } splice This method takes in a listref, and returns only the values which are on the current page: @visible_holidays = $page->splice(@holidays); skipped This method is useful paging through data in a database using SQL LIMIT clauses. It is simply $page->first - 1: $sth = $dbh->prepare( q{SELECT * FROM table ORDER BY rec_date LIMIT ?, ?} ); $sth->execute($page->skipped, $page->entries_per_page); change_entries_per_page This method changes the number of entries per page and the current page number such that the first item on the current page will be present on the new page. $page->total_entries(50); $page->entries_per_page(20); $page->current_page(3); print $page->first; # 41 $page->change_entries_per_page(30); print $page->current_page; # 2 - the page that item 41 will show in NOTES
It has been said before that this code is "too simple" for CPAN, but I must disagree. I have seen people write this kind of code over and over again and they always get it wrong. Perhaps now they will spend more time getting the rest of their code right... SEE ALSO
Related modules which may be of interest: Data::Pageset, Data::Page::Tied, Data::SpreadPagination. AUTHOR
Based on code originally by Leo Lapworth, with many changes added by by Leon Brocard <acme@astray.com>. CONTRIBUTORS
James Laver (ELPENGUIN) COPYRIGHT
Copyright (C) 2000-9, Leon Brocard LICENSE
This module is free software; you can redistribute it or modify it under the same terms as Perl itself. perl v5.18.2 2017-10-06 Data::Page(3)
All times are GMT -4. The time now is 03:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy