View Single Post
Old Feb 27th, 2005, 4:34 PM   #10
Vorlin
Newbie
 
Join Date: Feb 2005
Posts: 12
Rep Power: 0 Vorlin is on a distinguished road
In trying to understand your script and what you're doing with it, here's what I did.

I created a 'foo.dat' file in my home directory ($HOME in env var). In this file, there's a simple line that has '10:20:30:40' in it. I didn't know the format of your dat file but you said it was the first variable so here we go.

Then I created a global variable that was exported. Something to remember about exporting a variable from the command line is that it will only be available in that session unless you add it as an alias executed during your login or add it to the skeleton profile, etc...

$ /home/booyaka > export FOO=`cat $HOME/foo.dat | head -1 | awk -F: '{ print $1 }'`
$ /home/booyaka > echo $FOO
10

Or you could do something like this, just as an alternative:
$ /home/booyaka > export FOO=`cat $HOME/foo.dat | head -1 | cut -d: -f1`
$ /home/booyaka > echo $FOO
10

If you're trying to do something else, and I misinterpreted, my bad...

Last edited by Vorlin; Feb 27th, 2005 at 4:35 PM. Reason: Forgot to add tail part...
Vorlin is offline   Reply With Quote