2

how to check if the content of a file is "1"?

view story
linux-howto

http://www.linuxquestions.org – Question in C Language: i want to close the program if the content of the file /tmp/file_name is 1 (just the number 1). dont need to check all the time, just when start the program. something like this: Code: "read the /tmp/file_name" "check if the content of the file_name is 1" "if not, do something" what i need is very simple to do in shell script: Code: go=`cat /tmp/file_test`                # "cat /tmp/file_test" read the content of the file_test if [ "$go" -eq "1" ]; then              # if the content of the file_test is 1 echo "ok, ready to exit now";          # now i can put the exit command fi but i dont know how to do the same thing in C... (HowTos)