setting a UNIX environmental variable in a one-liner
Posted on 2004-04-23
I am looking to set an environmental varibale in a one liner that I will present to the operating system from a program. I need to find the 32 bit CRC checksum of a file, the UNIX for this would be...
Simple enough, except that this returns several columns of data, I know that I only need the first column which is the actuall checksum value so....
echo `cksum file.ext ` | cut -d" " -f1
Will get the data I need. I then need to present this to a setenv command and this is where I am having trouble with the syntax, all of the following do not work....
setenv MJMCKSUM `echo ``cksum file.ext ` | cut -d" " -f1``
setenv MJMCKSUM `echo `cksum file.ext ` | cut -d" " -f1`
I thought either of these would substitute the inner command to the cksum value and then use this value to set the MJMCKSUM environmental variable. Is there something wrong with my syntax or is this a two step operation?
Thanks in advance