- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Print text per page number
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
02-20-2003 07:23 PM
02-20-2003 07:23 PM
Print text per page number
I have a huge file on HPUX containing a report. The file contain like this:
Page 1
text
text
text
Page 2
text
text
text
Page 3
text
text
text
Page 4
text
and so on
I want to print it by particular pages. ie from page 1 to 3 or from page 2 to 4. How can I do this ?
Thanks in advance,
Joseph
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 07:33 PM
02-20-2003 07:33 PM
Re: Print text per page number
Like open the fine in vi then
:50,100 w file1
you'll get a file1 with those 50-100 lines and then print that file1 and later on delete it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 08:12 PM
02-20-2003 08:12 PM
Re: Print text per page number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 09:05 PM
02-20-2003 09:05 PM
Re: Print text per page number
My file size is 1GB so I am afraid to open it with vi. It's actually a oracle report that already submitted to print job, Unfortunately during printing the printer failed. So instead to run it on oracle and reprint it again I decided to print it on OS side. I want to start the print with the page where printing cut off.
Carlos
I tried your command but I didn't see any output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 11:34 PM
02-20-2003 11:34 PM
Re: Print text per page number
Perhaps you can use "split":
"split -l 1000" filename" splits the file into pieces with 1000 lines in each. Then you can print out any of the pieces you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2003 11:54 PM
02-20-2003 11:54 PM
Re: Print text per page number
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 05:17 AM
02-21-2003 05:17 AM
Re: Print text per page number
if you only want to print the lines from where printing stopped, you can perhaps make use of the tail command:
First, find a distinctive string in the last printed line and retrieve its line number, e.g.:
# grep -n "distinctive string"
which should return
# wc -l
Now calculate the position of the last printed line from the end:
# echo
Try printing the rest with tail, e.g.:
# tail -
Unfortunately, it might fail because of the limitations of tail and the size of your file.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 05:22 AM
02-21-2003 05:22 AM
Re: Print text per page number
# print paragraph if it contains AAA (blank lines separate paragraphs)
# HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'
# print paragraph if it contains AAA and BBB and CCC (in any order)
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'
# print paragraph if it contains AAA or BBB or CCC
sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
# print only lines of 65 characters or longer
sed -n '/^.\{65\}/p'
# print only lines of less than 65 characters
sed -n '/^.\{65\}/!p' # method 1, corresponds to above
sed '/^.\{65\}/d' # method 2, simpler syntax
# print section of file from regular expression to end of file
sed -n '/regexp/,$p'
# print section of file based on line numbers (lines 8-12, inclusive)
sed -n '8,12p' # method 1
sed '8,12!d' # method 2
# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files
# print section of file between two regular expressions (inclusive)
sed -n '/Iowa/,/Montana/p' # case sensitive
(The original document came to me through the courtesy of Princess Paula of Bromley)
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 07:09 AM
02-21-2003 07:09 AM
Re: Print text per page number
It should be :
awk '/Page 2/,/Page 4/ {print $0}' file
but if it is a oracle report then all line should be of same length and all page too, so
i.e.
linesize 80
pagesize 60
to print page 5 to 8
dd if=file of=output bs=4800 skip=5 count=4
will be a faster way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 07:48 AM
02-21-2003 07:48 AM
Re: Print text per page number
To print only a few pages in the middle of the file, again you need the line count of the beginning and end of the area you want to print. Call these BEGIN and END line numbers. Get both numbers with the "pr -n -t" command, as above. Then determine the LENGTH in lines that you want, by subtracting the BEGIN from the END. Finally, the command "tail -$BEGIN $FILE|head -$LENGTH|lp " prints just the lines that you identified with the BEGIN and LENGTH numbers.
Alternatively, if you have the line numbers, you can use sed. sed -n '$BEGIN,$ENDp'|lp"
There are probably more than a dozen ways to do this, but these are simple.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 11:21 AM
02-21-2003 11:21 AM
Re: Print text per page number
Here is my proposed solution:
#! /usr/bin/ksh
# filename: lspages
# usage: lspages
#
#
#
WIDTH=65
HEIGHT=66
LINES=`echo "$HEIGHT*(($3-$2)+1)" | bc`
pr +$2 -w$WIDTH -l$HEIGHT $1 | head -n$LINES
Cut and paste this script into a file and name it lspages. Then chmod u+x lspages. You can easily adjust the character width and height for each page with the variables in this script.
Here is an example on how to use this script:
lspages /tmp/myfile.txt 30 79 >> pgs30-79.txt
This will print pages 30 through 79 of myfile.txt. I put in no error checking due to the short amount of time I worked on it. Not overly complicated and should work just fine for you.
Regards,
Jason V.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2003 11:24 AM
02-21-2003 11:24 AM
Re: Print text per page number
I know that you will see this, but I felt that I had to correct myself on my example. The example would take those pages and pipe them into the pgs30-79.txt. Again I hope this helps.
Regards,
Jason V.