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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting a file. 2

Status
Not open for further replies.

jerehart

Programmer
Jun 10, 1999
61
US
Hey,

I want to create a script that builds the header for me, since I have to put this on a lot of files, and for it to generic like this:

####################
#
# File Name:
# Author:
#
# Revision History
# -----------------
#####################

Any one know a slick way to do this?
 
Looks like you need Perl's format capability.

You can define it as something like this;

format STDOUT =
#############################
File Name: @<<<<<<<<<<
$name
Author: @<<<<<<<<<<<<<<<<<<<<
$author
#############################
.

You then just assign values to $name and $author and use the write() function to write the format.

See the perlform manpage for much better details on using formats.
 
Use perl's in-place edit (man perlrun):

perl -pi '*.bak' -e 'BEGIN { print &quot;#####\n#\n# File name:\n# Author:\n#\n# Revision History:\n# --------\n######&quot;; }' fileA fileB fileC fileD

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top