You are not logged in.
can we redirect output of a command to a variable in a shell script
the following are the commands used
set var1 = " "
basename test.tif.gz .gz > var1
or the other way
set the variable from the file
basename test.tif.gz .gz > outputfile
set var1 = < outputfile
In your shell just do this (i'm using bash):
[ascotto@localhost ~]$ test=`uname` [ascotto@localhost ~]$ echo $test Linux
explanations: "test" is the variable and using the `` quotes (sorry i don't remember the name) just do exactly what you want, it executes the command.`` replace the command with the result of the command.
Sorry my english sucks for such explanations... i feel like a 5 years old boy trying to explain something...
With bash you have other way to do that, search for "command substitution" in the manpages.
But you can do this:
Each shell has its own features so just look into specific manpages. Anyway the first method i showed you may work almost everywhere (except for csh based shells that i don't use).
Remember one thing, like RobSeace said: "CSH-based shells are the spawn of satan" :-)
gethostbyintuition() is still a dream of mine
-- quoted from bash