Hey, guys!
Trying to research this is such a pain since the
read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword.
So, I wanted to use a command statement similar to the following.
This is kinda taken from another question I posted recently about string manipulation and extracting portions of a string (in order to store to variable, via command substitution).
$ TEMPFILE=`ls -1 *31AUG2010.txt`
yields $TEMPFILE=filetransfers_31AUG2010.txt
$ read DD MM YY<enter>
> `echo ${TEMPFILE:14:2}` `echo ${TEMPFILE:16:3}` `echo ${TEMPFILE:19:4}`<enter>
which yields:
$DD=`echo
$MM=${TEMPFILE:14:2}`
$YY=`echo ${TEMPFILE:16:3}` `echo ${TEMPFILE:19:4}`
As you can see, I had intended for each variable to store the output from each command substitution set, but instead stored the literal values between each space encountered on the following input lines. BOOOOO!!
I don't even know if what I'm attempting to do is possible, I wanted to do this in a for loop, storing a new corresponding value for each variable per command set iteration.
Anybody have any experience with this, or how to get command substitution output to work with the read command?
I know that I could just do the command substitution independently for each variable in the loop, but now I'm just curious to know if it's possible to accomplish in one line using the
read command.
This is just for my curiosity, but I'd appreciate if somebody could educate me on this matter.