Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i use checksum command in my batch file and the output of command as follow :

69514a29dc44cd83b42658e917ed9baf *file.txt

i want to return checksum only so i should store it in variable without file.txt like

CHECKSUM=69514a29dc44cd83b42658e917ed9baf

how i can do this maybe write output of command to file then read this file ??? if yes how i can read just first 32 bits from file and store it in variable ????

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can use a sort of 'left'-function in batch:

set str=69514a29dc44cd83b42658e917ed9baf *file.txt
echo.%str%
set str=%str:~0,32%
echo.%str%

More info on string manipulation in dos/batch: Link

share|improve this answer
    
but if i want to store result from command itself how i can do this i try to do set str=checksum file.txt but not work –  Mohammad AL-Rawabdeh Mar 10 '11 at 11:57
    
See: serverfault.com/questions/245679/… –  Bart De Vos Mar 10 '11 at 14:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.