- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to print certain pages from a disk file
Operating System - Linux
1752766
Members
5204
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2005 11:29 AM
тАО08-16-2005 11:29 AM
Hi all
I want to print a range of pages from a disk file (a lengthly report). As I need to pass 3 arguments to this script, so the syntax will be "prnpage.sh filename from_page to_page". The pages are not fixed length because of control breaks. (eg. print by sales rep by state etc). On the report, there is a control code "^L" to denote new page.
I managed to print a range of pages successfully if number of detail lines on pages are the same.
Also, how can I grep the "^L"?
Any idea to tackle this problem is appreciated.
Thanks in advance.
Davis
I want to print a range of pages from a disk file (a lengthly report). As I need to pass 3 arguments to this script, so the syntax will be "prnpage.sh filename from_page to_page". The pages are not fixed length because of control breaks. (eg. print by sales rep by state etc). On the report, there is a control code "^L" to denote new page.
I managed to print a range of pages successfully if number of detail lines on pages are the same.
Also, how can I grep the "^L"?
Any idea to tackle this problem is appreciated.
Thanks in advance.
Davis
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2005 02:00 PM
тАО08-16-2005 02:00 PM
Re: How to print certain pages from a disk file
You can try using software called a2ps.
$ a2ps --interpret=yes --pages=1-3 --output test.ps test.txt
--interpret=yes makes it interpret form feed character (^L) as page break
--pages to select what pages to print
--output for testing then examine test.ps to make sure it's what you expect
You can download a2ps from
http://hpux.connect.org.uk
or the closest mirror
$ a2ps --interpret=yes --pages=1-3 --output test.ps test.txt
--interpret=yes makes it interpret form feed character (^L) as page break
--pages to select what pages to print
--output for testing then examine test.ps to make sure it's what you expect
You can download a2ps from
http://hpux.connect.org.uk
or the closest mirror
- Tags:
- a2ps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2005 08:50 PM
тАО08-16-2005 08:50 PM
Solution
To get the ^L search pattern type Quote CTRL-V CTRL-L Quote. i.e. hold down the CTRL key and press V then L without letting go of the control key.
A basic script could be something like ...
FILE=$1
FP=$2
LP=$3
if [ "$FP" -eq 1 ]
then
FL=0
else
FP=`expr $FP - 1`
FL=`grep -n "^L" $1 | cut -f1 -d":" | head -$FP | tail -1`
fi
TP=`grep -n "^L" $1 | wc -l`
if [ "$LP" -gt "$TP" ]
then
LL=`wc -l $1 | awk '{ print $1 }'`
else
LL=`grep -n "^L" $1 | cut -f1 -d":" | head -$LP | tail -1`
fi
TL=`expr $LL - $FL`
head -$LL $1 | tail -$TL
Where TP=total pages, TL=total lines, FP=first page, FL=first line, LP=last page, LL=last line. You might have to change it depending on whether the last page in the file has a ^L at the end of it or not. Also what do you want to do if they request page 6 of a 5 page document? The script above would print the last page in the document in response.
A basic script could be something like ...
FILE=$1
FP=$2
LP=$3
if [ "$FP" -eq 1 ]
then
FL=0
else
FP=`expr $FP - 1`
FL=`grep -n "^L" $1 | cut -f1 -d":" | head -$FP | tail -1`
fi
TP=`grep -n "^L" $1 | wc -l`
if [ "$LP" -gt "$TP" ]
then
LL=`wc -l $1 | awk '{ print $1 }'`
else
LL=`grep -n "^L" $1 | cut -f1 -d":" | head -$LP | tail -1`
fi
TL=`expr $LL - $FL`
head -$LL $1 | tail -$TL
Where TP=total pages, TL=total lines, FP=first page, FL=first line, LP=last page, LL=last line. You might have to change it depending on whether the last page in the file has a ^L at the end of it or not. Also what do you want to do if they request page 6 of a 5 page document? The script above would print the last page in the document in response.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-18-2005 10:52 AM
тАО08-18-2005 10:52 AM
Re: How to print certain pages from a disk file
Thanks to Ermin & Stephen. My scripts are working perfectly now.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP