tcsh

How to store the output of a command into a variable in TCSH?


in bash this clearly works

$ now=$(date "+%F")
$ echo $now
2022-07-20

but in tcsh:

>> now=$(date "+%F")
Illegal variable name.

Is there a way to store such a thing into a var?


Solution

  • csh doesn't support $() for command execution, only backticks. And you need to use set to assign variables.

    % set now = `date "+%F"`
    % echo $now
    2022-07-20