Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I page only if neccessary ? 1

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
I want the following script to "pg" or "more" only if the result is greater than 1 page ;
-------------------
for file in `ls s*`
do
echo $file
done
-----------------
Adding the pg or more at end of the echo line does not work.
 
a=`ls s* | wc -l`

if [ $a > "36" ] # 36 = screen line length
then
for file in `ls s*`
do
pg $file
done
else
for file in `ls s*`
do
cat $file
done
fi --
| Mike Nixon
| Unix Admin
| ----------------------------
 
Another possibility is to use `more -e` which exits the file automatically after the last line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top