0

I have a question regarding sending data from a file line by line to a C program that will then convert the data's values from Fahrenheit to Kelvin. How do I read in the program line by line and then grab the output line by line back into my script?

3
  • So you have a file that has a list of temperatures, and you want to get the converted temperature for each one, so you can do something with each one? If so, you can look here for part of it Commented Dec 7, 2016 at 16:45
  • How does the C program read the data? Commented Dec 7, 2016 at 19:39
  • What is wrong with reading one line a time in the C program? I do not understand why you would want something like while read -r line; do cprog "${line}"; done. Commented Dec 7, 2016 at 21:59

1 Answer 1

1

It's not really clear what is required here because the interface to the converter program is not specified. Assuming that the program is called f2k, that it reads Fahrenheit values one-per-line from standard input and writes the converted values one-per-line to standard output, and that the file fahrenheits.txt contains a list of Fahrenheit values, one-per-line, this will put a newline-separated list of the Kelvin values into the kelvins variable:

kelvins=$(f2k <fahrenheits.txt)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.