Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file which gets generated based on the arguments and it has the following contents.


Now, these are actually date partitions for hive query. So, I want to use them in my hive query where I specify each of these partitions in WHERE clause. Something like below

 WHERE log_date IN ('2012-12-31','2012-12-30', '2012-12-29')

So, I am looking the output from paste as


I am using the following, but I think the -d parameter is a list of delimiter and not one complete delimiter.

paste -sd"','" datefile

Any idea how can I do that?

share|improve this question
up vote 3 down vote accepted

Using sed and paste together:

$ sed "s/.*/'&'/" file | paste -sd,
share|improve this answer
Nice. I too used something similar. I added a single delimiter with paste and then used sed to replace it with actual one. paste -sd"," datefile | sed "s/\,/'\,'/g" – divinedragon Jan 17 '13 at 13:11


echo  "WHERE log_date IN ('$(sed -e :a -e "$!N; s/\n/','/; ta" datefile)')"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .