LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can I pass the contents of a file into an integer? (https://www.linuxquestions.org/questions/programming-9/how-can-i-pass-the-contents-of-a-file-into-an-integer-702031/)

andrew22 02-03-2009 04:14 PM

How can I pass the contents of a file into an integer?
 
I am trying to make a .sh programm , which will read the user input , pass it into an integer , write the integer into a file , then read the file , pass the contents of it in another integer , and the echo the last integer I am trying this
Code:

#! /bin/bash
touch value
read val
echo "$val" > value
cat value | set $val2
echo "$val2"

but , after all , is SET for that porpuse ? Can you give mesome corrections?

Maligree 02-03-2009 04:29 PM

This should work..
Code:

read value1
echo $value1 > value_file
value2=`cat value_file`
echo $value2



All times are GMT -5. The time now is 09:01 AM.