I'm having issues getting redirection to work in Terminal. I'm in a C++ class where we have to create an application, then find that application in the Terminal and place a text file in the same folder. That text file then has to be used as the input to the Terminal application we created in C++. So, after building my application and placing it and a .txt file in a folder, I open the Terminal, navigate to that directory, then use:
program < textfile
or more specifically in my case:
redirect < input.txt
but it doesn't work. I keep getting: "-bash: redirect: command not found"
I'm using the method our teacher told us to use based on windows command line, but I'm betting its not the same format for Terminal on Mac. I've been googling the issue for about a week and still have not figured it out. Any help would be greatly appreciated.
EDIT:
Added a photo:
EDIT2:
Best Answer
Far less can go wrong if you pipe the input:
In your case,
./program
might be needed depending on where you are compiling things or omitting the path entirely. From your edit this should work too:That bash error is due to the program not existing in
$PATH