Quantcast
Viewing all articles
Browse latest Browse all 10

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 “,”.


Viewing all articles
Browse latest Browse all 10

Trending Articles