0x90
0x90

Reputation: 40982

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?

Upvotes: 0

Views: 725

Answers (1)

Martin Tournoij
Martin Tournoij

Reputation: 27822

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

Upvotes: 2

Related Questions