msgbartop
Tips, notes, HOWTOs
msgbarbottom

15 Feb 10 When grep and sed are not enough…

I found an article over at Linux Journal that lead with the sentence:

When grep and sed aren’t enough, gawk may provide the extra horsepower that you need.

I would have to argue against that.  Nothing personal against gawk, awk itself, or any of it’s variants.  I personally love awk.  Though I would rewrite their first sentence a bit.

When grep and sed aren’t enough, you obviously don’t know enough grep and sed.

At any rate he does provide some gawk examples that aren’t totally worthless but certainly don’t require it over grep and/or sed.  I am guessing that there will be some decent examples either way in the comments section as well.

Tags: , , , ,

23 Jan 09 Add A Comma To The End Of A Line

I work with long lists and WinSQL a lot.  I always find myself wishing these long lists had commas at the end for pasting into a SQL where clause using “IN” for the list.  This can be accomplished in one of two ways.

From the command line:

sed "s/$/,/g" <FILENAME>

I usually pipe the output there to a new file.

In vi (from command mode):

:%s/$/,/g

The “%” says to perfom the substitution on the whole file.  In both cases we are doing a substitution of “$” (the end of the line) with a “,”.

Tags: , , , ,

06 Dec 08 Remove Whitespace From The End Of Lines

Nice sed tip to remove extra whitespace at the end of lines in a file.

sed -e 's/ *$//' <file>

Tags: ,

SEO Powered by Platinum SEO from Techblissonline