On Friday 06 June 2008 12:59, Malte Forkel wrote: > I recently came across the following example for switching time > zones: > > $ date > Fr 6. Jun 12:49:30 CEST 2008 > $ TZ=UTC date > Fr 6. Jun 10:49:35 UTC 2008 > > Could someone please explain to me the general shell syntax involved > here? I did not know that I could put an assignment and a command on > one line. My dull approach would have been [...]
The 'date' command runs in a child process for which the bash shell has to determine the environment. Parameter assignments are inherited in that environment (i.e. the 'date' command sees them) in two cases: either when the variable is not only declared but also exported or when the assignment is provided on the command line right before the command itself. From the man page: The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described above in PARAMETERS. These assignment statements affect only the environment seen by that command. For more information you may want to read the "Command execution environment" section in the Bash man page. Best regards. Alfredo -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]