Reading files and saving output with Ollama

#ollama

Reading files and saving output with Ollama

There is a way to save an output from an model using ollama via the terminal.

$ollama run llama3.2 hello >> response.txt

$ollama run llama3.2 goodbye >> response.txt

$type response.txt
Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?

Goodbye! It was nice chatting with you, even if it was just for a short time. If you even want to come back and chat again, I'll be here. Have a great day!

First would be to run ollama and select the model you wish to use for the prompt.
Then pass the output to a .txt file.

Is there a way to have ollama read a text file?
Similar to the above.

Pipe the value of the cat command to the selected model and save the response to ollamaresponse.txt.

cat <file_to_read> | ollama run gemma3 >> ollamaresponse.txt

Electric Meatball's Digital Garden Home
Linux Terminal Cheat Sheet
Terminology📖