Sergei G Sergei G - 5 years ago 264
Bash Question

set variable on the same line as command

In sh programming I can do:

dryrun="echo " ./

And script uses it as:

${dryrun}ls -l (as an example)

I can't seem to figure out how to call script in csh with the same effect

Answer Source

An easy solution is to use the env command:

env dryrun=echo ./

This will work with pretty much any shell. The env command takes a list of var=value pairs and adds them to the environment of whatever command is at the end of the list. See man env for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download