Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 csv that I want to add a preceding column to and a trailing column. The trailing column is a date (manual string right now). Every time I try to get that date, it ends up replacing some text at the front of the read in data (print $0).

How can I add that info?

Sample data from stdin



awk -F, '{ printf ", %, %s\n", $0,"12\/15\/2012"}'


, 12/15/2012 1089, 19.3, -0.1

desired results


I've even tried separating the fields into individual columns, same result. Tried triple double-quotes around the date, same results (maybe an error i can't remember). What am I doing wrong with that date?

share|improve this question

closed as off-topic by terdon May 13 '15 at 14:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – terdon
If this question can be reworded to fit the rules in the help center, please edit the question.

Works here if you add another %s to the format specification. – Thor Feb 16 '13 at 21:40
Yeah, here with gnu awk 4.0.1 your original awk command with a %s in place of the lone % works.: awk -F, '{printf ",%s, %s \n", $0, "SOME_DATE"}' – SuperMagic Feb 16 '13 at 21:46
I suspect that's what you meant to type. In any event, I also can't reproduce your indicated results even with the presumed typo.... – SuperMagic Feb 16 '13 at 21:49
ok, thanks for the tip! from my examples, I can't get it to fail either. must be something in the stdin. "cat "ls -t | head -1" | tail -n+9 | awk ..." which i can rework now that i started to use awk. – greenwar Feb 16 '13 at 21:54
You do not need to escape the / between double-quotes. – Johan Apr 15 '14 at 15:44

Browse other questions tagged or ask your own question.