home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 21.8 The MAILCHECK and mail Variables Check More than Mail Chapter 21
More About Managing Files
Next: 21.10 Keep a Directory Listing at Top of the Screen: dirtop
 

21.9 Keep File Printouts Up-to-Date Automatically with make

A lot of people think that the make ( 28.13 ) utility is just for programmers. But it's also good for people who need to do something when files have been modified.

I'll show you a makefile that lets you be sure you have printouts of the latest versions of certain files in a directory. Any time you think files have been modified, just type:

% 

make print


pr chap1 chap5 | lpr -Pxyz
touch print

make saw that the files chap1 and chap5 had been modified since the last print job. So it used pr and lpr to print the files. Then it ran touch ( 21.7 ) to create or update the empty file named print ; the "timestamp" (modification time) of this empty file keeps a record of when these other files were printed. Or, the command make printall will print all files any time without updating the print timestamp file.

Here's the makefile . Change the names and the print commands to do what you want. Remember that each command line (here, the lines starting with pr and touch ) must start with a TAB character:


LPR = lpr -Pxyz
FILES = preface chap1 chap2 chap3 chap4 chap5 appendix

print: $(FILES)
    pr $? | $(LPR)
    touch print

printall:
    pr $(FILES) | $(LPR)

- JP


Previous: 21.8 The MAILCHECK and mail Variables Check More than Mail UNIX Power Tools Next: 21.10 Keep a Directory Listing at Top of the Screen: dirtop
21.8 The MAILCHECK and mail Variables Check More than Mail Book Index 21.10 Keep a Directory Listing at Top of the Screen: dirtop

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System