Wrapping text around a string with sed & functionality

Need to use sed to do a string replacement.


# Comments until end of line

Should be:

<span class=comment>#Comments until end of line</span>

This can be accomplished with sed by using the ‘&’ operator which pastes in the match space.


Script started on Mon 01 Aug 2011 04:47:45 PM CDT

deadlycoffee:/tmp #  sed 's/^#.*.$/(&)' test | sed 's/^#$/(&)/' 
this is not a comment
this isn't either
(## This is)
(# So is this.)
deadlycoffee:/tmp #  exit 

Script done on Mon 01 Aug 2011 04:48:52 PM CDT


In the above example, I do a much simpler replacement, but it is the same idea.

Reporting Packages

Is it possible for a reporting solution to both ‘look’ sufficiently effective to be purchased by the average IT department and ‘be’ sufficiently effective to accomplish anything of value? This is the real question and it seems sad that solutions may have to either pick one side or the other.

Don’t try this as root

Contexts of a tiny script that you should never run:

cp $0 $$ # Make a copy of yourself
sh $$ & # Run the copy in the background
sh $0 & # Rerun a new version of yourself in the background

This will probably take over your server or at least use up all of the filesystem pointers in its filesytem. In a minute or so you would have thousands of these running and doubling each generation.

This does demonstrate an interesting version of ‘the game of life’. If the copy (cp) could be a little less reliable and the whole thing could work in a few messed up ways, this could actually evolve into some other different tiny script.

Self-reference is always fun times.