Friday, 15 April 2011

Bash concatenate strings results in each variable within quotes -


I am trying to add 2 variables to the string in the bash. I have seen many posts on this and for some reason they do not work for me. This is my script which takes only one filename prefix and adds the current date till the end.

  #! / Bin / bash now = $ (date + "% Y% m% d") instead of  instead of  "file" "20150316"  fname = "file" x = $ fname $ now Echo $ x  

File20150316 ".

Please help please.

You are using incorrect quotes (Unicode is not the actual ASCI ones). Try this:

  #! / Bin / bash now = $ (Date "+% Y% m% d") fname = "file" x = "$ fname $" now "echo" $ x " 

No comments:

Post a Comment