title: Nested expression in a UNIX shell script
body: <p>I have a script to download files using scp and then save files by appending current date.</p>
  
  <p>I got error message:</p>
  
  <pre><code>local_computer:~ memo$ ./scp_auto_save.sh 
  can't read "(date +%d-%m-%y)": no such variable
  while executing
  "spawn scp "root@ch1.local:/root/*.csv" ./ch1_$(date +%d-%m-%y).csv"
  (file "./scp_auto_save.sh" line 4)
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>#!/usr/bin/expect -f
  # connect via scp - ch1
  spawn scp "root@ch1.local:/root/*.csv" ./ch1_$(date +%d-%m-%y).csv
  expect {
  -re ".*es.*o.*" {
  exp_send "yes\r"
  exp_continue
  }
  -re ".*sword.*" {
  exp_send "password\r" 
      } 
  }
  interact
  </code></pre>
  
  <p>Q1:
  How to correctly express $(date +%d-%m-%y) inline with the scp command?</p>
  
  <p>Q2:
  I have many files stored in 20 remote machines. How to scp each machine? </p>
  
  <p>For example:</p>
  
  <pre><code>spawn scp "root@ch1.local:/root/*.csv" ./ch1_current_date.csv
  spawn scp "root@ch2.local:/root/*.csv" ./ch2_current_date.csv
  :
  :
  spawn scp "root@ch20.local:/root/*.csv" ./ch20_current_date.csv
  </code></pre>
  
  <p>Thanks for your help.</p>