Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting an ENV VAR in a one liner?

Status
Not open for further replies.

mjm22

Programmer
Nov 11, 2003
10
GB
Hi

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...

cksum file.ext

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

Mike
 
your quoting is incorrect. Assuming csh/tcsh:

setenv MJMCKSUM `cksum file.ext | cut -f1`

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top