Assinging variables via commands in a cshell skript

It is more or less well known that the ouput of a shell command can be redirected to a file via “>”. To assign a variable with the value of the command output, one has to use the quotes ` ` instead of ” ” or ‘ ‘ . For example,

$ set var = ` cat * | grep “text” | cut -d . -f1`

leads to evaluation of the command and assigning the result to the value of the variable var. This makes sense in all cases where the result of the command should not only be stored but is used in further commands.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.