csh script -> compose string ..Stupid question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • diSangro
    New Member
    • Jan 2007
    • 69

    csh script -> compose string ..Stupid question

    Hello community,

    I have a stupid question...of course Im not expert of csh scripting
    I couldn't get how to compose a string in a csh script.

    suppose I have:

    set STR1 = "text1"
    set STR2 = "text2"

    How to compose a string which has STR1 appended to STR2 ?

    I tried:

    set STR3=`echo $STR1$STR2`

    its not workin...syntax error...but typing

    echo $STR1$STR2

    produces the desired output on csh cmd line...why?
    Thankz in advance
  • diSangro
    New Member
    • Jan 2007
    • 69

    #2
    The correct way is:

    set STR3 = $STR1$STR2

    Thankz anyway...

    Originally posted by diSangro
    Hello community,

    I tried:

    set STR3=`echo $STR1$STR2`

    its not workin...syntax error...but typing

    echo $STR1$STR2

    produces the desired output on csh cmd line...why?
    Thankz in advance

    Comment

    • Motoma
      Recognized Expert Specialist
      • Jan 2007
      • 3236

      #3
      Glad you found your answer. Thank you for posting the solution for us.

      Sorry, I think we were all asleep between when you asked and when you arrived at the solution.

      Come back any time you have a problem,
      Motoma

      Comment

      • egsauer
        New Member
        • Feb 2008
        • 1

        #4
        Originally posted by diSangro
        Hello community,

        I have a stupid question...of course Im not expert of csh scripting
        I couldn't get how to compose a string in a csh script.

        suppose I have:

        set STR1 = "text1"
        set STR2 = "text2"

        How to compose a string which has STR1 appended to STR2 ?

        I tried:

        set STR3=`echo $STR1$STR2`

        its not workin...syntax error...but typing

        echo $STR1$STR2

        produces the desired output on csh cmd line...why?
        Thankz in advance
        Try this,

        #!/bin/csh

        set a = 123
        set b = abc
        set c = `printf "%s%s" $a $b`
        echo $c

        Comment

        Working...