Search code examples
cshtcsh

Subshell stdout n tcsh


In bash I get the stdout of a subshell block and assign it to a varaiable like:

$ VAL="$(ls)"

How can this be done in tcsh?


Solution

  • Use backticks to get the output and use set to assign it to a variable

    examples:

        $ set val=`ls`
        $ set val=`ls | grep foo`
    

    to clear the variable use unset val

    See http://www.grymoire.com/Unix/Csh.html for more examples and information on csh / tcsh