#!/bin/bash
./program < input.txt > output.txt
The > output.txt part is being ignored so output.txt ends up being empty.
This works for the sort command so I expected to also work for other programs.
Any reason this doesn't work? How should I achieve this?
The most likely explanation is that the output you're seeing is from stderr, not stdout. To redirect both of them to a file, do this:
./program < input.txt > output.txt 2>&1
or
./program < input.txt &> output.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With