Sponsored Content
Top Forums Shell Programming and Scripting Awk: Page number with total number of pages, EG Page 1 of 5 Post 303043184 by vgersh99 on Monday 20th of January 2020 09:58:23 PM
Old 01-20-2020
Quote:
Originally Posted by tugar
Hi vgersh99,

They should be the same as there are only 3 pages in total in my sample file. It looks like the final output has the original 3 pages without the string "This is the last line of the page" with no page numbers followed by the same 3 pages with the string including the page numbers.
Sorry, my bad:
Code:
awk -F';' '
  FNR==NR { if (/This is the last line of the page/) total++;next}
  /This is the last line of the page/{printf("%s\nPage No:%d of %d\n", $0, ++page, total);next}1' textfile1  textfile1  > textfile12


Last edited by vgersh99; 01-20-2020 at 11:52 PM..
 

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
DVISELECT(1)						      General Commands Manual						      DVISELECT(1)

NAME
dviselect - extract pages from DVI files SYNOPSIS
dviselect [ -s ] [ -i infile ] [ -o outfile ] list of pages [ infile [ outfile ] ] DESCRIPTION
Dviselect selects pages from a DVI file produced by TeX, creating a new DVI file usable by any of the TeX conversion programs, or even by dviselect itself. A range is a string of the form even, odd, or first:last where both first and last are optional numeric strings, with negative numbers indicated by a leading underscore character ``_''. If both first and last are omitted, the colon may also be omitted, or may be replaced with an asterisk ``*''. A page range is a list of ranges separated by periods. A list of pages is described by a set of page ranges sepa- rated by commas and/or white space. Dviselect actually looks at the ten count variables that TeX writes; the first of these (count0) is the page number, with count1 through count9 having varied uses depending on which macro packages are in use. (Typically count1 might be a chapter or section number.) A page is included in dviselect's output if all its count values match any one of the ranges listed on the command line. For example, the com- mand ``dviselect *.1,35:'' might select everything in chapter 1, as well as pages 35 and up. ``dviselect 10:30'' would select pages 10 through 30 (inclusive). ``:43'' means everything up to and including page 43 (including negative-numbered pages). To get all even-num- bered pages, use ``even''; to get all odd-numbered pages, use ``odd''. If a Table of Contents has negative page numbers, ``:_1'' will select it. Note that ``*'' must be quoted from the shell; the empty string is more convenient to use, if harder to read. Instead of count values, dviselect can also select by ``absolute page number'', where the first page is page 1, the second page 2, and so forth. Absolute page numbers are indicated by a leading equal sign ``=''. Ranges of absolute pages are also allowed: ``dviselect =3:7'' will extract the third through seventh pages. Dot separators are not legal in absolute ranges, and there are no negative absolute page numbers. Even/odd specifiers, however, are legal; ``dviselect =even'' selects every other page, starting with the second. More precisely, an asterisk or an empty string implies no limit; an equal sign means absolute page number rather than counts; a leading colon means everything up to and including the given page; a trailing colon means everything from the given page on; the word ``even'' means only even values shall be accepted; the word ``odd'' means only odd values shall be accepted; and a period indicates that the next count should be examined. If fewer than 10 ranges are specified, the remaining counts are left unrestricted (that is, ``1:5'' and ``1:5.*'' are equivalent). A single number n is treated as if it were the range n:n. An arbitrary number of page selectors may be given, separated by commas or whitespace; a page is selected if any of the selectors matches its counts or absolute page number. Dviselect normally prints the page numbers of the pages selected; the -s option suppresses this. AUTHOR
Chris Torek, University of Maryland SEE ALSO
dviconcat(1), latex(1), tex(1) MC-TeX User's Guide The TeXbook BUGS
A leading ``-'' ought to be allowed for negative numbers, but it is currently used as a synonym for ``:'', for backwards compatibility. Section or subsection selection will sometimes fail, for the DVI file lists only the count values that were active when the page ended. Clever macro packages can alleviate this by making use of other ``free'' count registers. Chapters normally begin on new pages, and do not suffer from this particular problem. The heuristic that decides which arguments are page selectors and which are file names is often wrong. Using shell redirection or the -i and -o options is safest. Dviselect does not adjust the parameters in the postamble; however, since these values are normally used only to size certain structures in the output conversion programs, and the parameters never need to be adjusted upward, this has not proven to be a problem. DVISELECT(1)
All times are GMT -4. The time now is 04:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy