Pages

mercredi 28 mars 2012

concatenate strings in csh

set a = "/home/user"
set b = "ss"
set c = 2.2

The following works:
echo  input$a"/"$b"_tt"$c".txt"
echo  input$a/$b"_tt"$c".txt"
echo  "input$a"/"$b"_tt"$c".txt""
echo  "input"$a"/"$b"_tt"$c".txt"
echo  ""input"$a"/"$b"_tt"$c".txt""


The following does not work:
echo  input$a"/"$b_tt$c".txt"


 Note: to concatenate a variable with a string, the following works:
$variable"string"   or   "$variable"string""
$variable"_string"
$variable"*string"
$variable"/string"   or $variable/string
$variable".string"   or $variable.string


if string is before the variable, then we can omit the double quote often:
string$variable    or "string"$variable
string_$variable  "string_"$variable
string/$variable   "string/"$variable

Aucun commentaire:

Enregistrer un commentaire