Please click this logo to help me get on their beta program:

Xobni outlook add-in for your inbox








2/6/2005

Adding headers to files in a batch

Filed under: General, Programming — Oliver Sturm @ 8:44 pm - 3 years, 4 months ago

Valery just posted a blog article about a tool to insert headers in a bunch of files. I don’t have too much to say about that, but the comment form on the blog didn’t want me to post the following (a server error message about a potentially dangerous form post, lol), so I thought I’d just put it in my own blog instead. Here’s the comment I wanted to post:

Wow! That’s some solution for a tiny problem… How about a small shell script:

#!/bin/sh
	
for file in *.cpp; do
  cat my_new_header > $file.new
  cat $file >> $file.new
  mv -f $file.new $file
done

Certainly not the most elegant solution, but just as certainly it does the job and takes only a few seconds to write when needed.

1 Comment »

  1. :-)
    Looks that processing of my blog comments is better than I thought -
    it didn’t allow such dangerous scripts through, didn’t it :D
    Oliver, that script would do the job… And I did think of similar script
    before I started writting my C++ program, frankly :) .

    -Valery.
    http://www.harper.no/valery

    Comment by Valery Pryamikov — 3/6/2005 @ 5:29 am - 3 years, 4 months ago

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Powered by WordPress
© Copyright 2005-2008 Oliver Sturm