0

I have been trying to do a string replace of .txt filenames within an .properties file using the sed shell command in the SCons' env.Command function. I am currently failing to understand how to append a timestamp to these filenames within this file.

Naively I attempted to use bash variables within the build step as follows:

 env.Command('foo.out', 'foo.in', "dateVar=$(date +%F-%k-%M); sed -i \"s/\.txt/\.txt?v=$dateVar/g\" example.properties");

...but that only led to failures as SCons attempted to parse anything with a dollar sign. Does anyone know how I can achieve this append?

Traker
  • 2,147
  • 3
  • 23
  • 38
  • Can you explain a bit more about the different files. What is in example.properties, foo.out, and foo.in? As I understand it, you want to read file names from example.properties and append a timestamp. Where do you want to save the results? – Brady Sep 14 '12 at 07:41

1 Answers1

1

Protect the $ from the SCons parser by writing it as $$:

env.Command('foo.out', 'foo.in',
            'dateVar=$$(date +%F-%k-%M); '
            'sed -i "s/\.txt/\.txt?v=$$dateVar/g" example.properties');
user4815162342
  • 141,790
  • 18
  • 296
  • 355