10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
HI,
I am using below command to display the words, but i am getting awk error. Please help me out on this
I am using below code
i am getting error as
If i use below code i am getting below OP
Output from where i am trying to select the fields after delimiter ","
from here i want to... (5 Replies)
Discussion started by: darling
5 Replies
2. Shell Programming and Scripting
this works:
cat file.txt| awk 'NR==45,NR==55'
but how do I assign variables instead of numbers:
this does not work:
cat file.txt | awk 'NR==$start,NR==$end'
there need variables instead of numbers
Sorry for my English
Thank you for answer (3 Replies)
Discussion started by: gizmo16
3 Replies
3. Shell Programming and Scripting
I need to extract selected lines from a log file, I can use grep to pull one line matching 'x' or matching 'y', how can I run through the log printing both matching lines in order top to bottom.
i.e
line 1 xyz - not needed
line 2 User01 - needed
line 3 123 - not needed
line 4 Info - needed... (2 Replies)
Discussion started by: rosslm
2 Replies
4. Shell Programming and Scripting
I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by
awk 'NR==29,NR==10029' File1 > File2
and then doing
awk '{print $1, $2, $13, $14}' File2 > File3
Can... (3 Replies)
Discussion started by: ananyob
3 Replies
5. UNIX Desktop Questions & Answers
1 I open pdf file - it has empty borders of space without text
2 I want to print 9 pages to save paper & eyes
3 In Okular i choose print - 9 pages. And I have no option for adjusting text to text (to print without spaces among 9 pages).
What program can you recommend to me for this... (1 Reply)
Discussion started by: Xcislav
1 Replies
6. Shell Programming and Scripting
I have learned file comparison from my previous post here. Then, it is comparing the whole line. Now, i have a new problem.
I have two files with 3 columns separated with a "|". What i want to do is to compare the second and third column of file 1, and the second and third column of file 2. And... (4 Replies)
Discussion started by: kingpeejay
4 Replies
7. Shell Programming and Scripting
Hi,
I want to print particular chars in a string. for example
ie.,
consider " dear,. roopa$#09%~`';']" as the example string. Here, I want to print only alphanumeric chars..
suppose , if i want only alphanumeric... value would be "dear roopa09"
suppose , if i want some spl char(,) with... (2 Replies)
Discussion started by: balan_mca
2 Replies
8. Shell Programming and Scripting
Hi can anyone assist me on my problem.
I try to grep 1 word in 1 line data. Example like below.
* Data below located in a.txt, i just wanna grep just processing-time = "12"
total-octets = "20080718214210Z" total-pages = "" octets-completed = "20080721064351Z" pages-completed = "2"... (10 Replies)
Discussion started by: anakiar
10 Replies
9. Shell Programming and Scripting
Hi everybody:
I try to print in new file selected lines from another file wich depends on the first column.
I have done a script like this:
lines=( "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "21" "31" "41" "51" "55" "57" "58" )
${lines}
for lines in ${lines}
do
awk -v ... (6 Replies)
Discussion started by: tonet
6 Replies
10. Shell Programming and Scripting
Hi everybody:
Could anybody tell me how I can print from a file a selected rows with awk. In my case I only want print in another file all the rows from NR=8 to NR=2459 and the increment each 8 times.
I tried to this:
awk '{for (i=8; i=2459; i+=8); NR==i}' file1 > file2
But doesn't... (6 Replies)
Discussion started by: tonet
6 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)