What im also supposed to do is if there is no arguments i am supposed to print a "help" message to the standard error device using cat. So far i can understand and get it to work using echo but my task is to do this using cat only. When i try the line cat 2> (help message)
it goes to a new line where i can type anything and causes the script to not work correctly at all the only escape being ctrl + z
. How can this be done using cat instead of echo? With the stderr message still being printed out as well if thats possible using only cat?
Help Message
Usage: concat FILE ...
Description: concatenates FILE(s) to standard output separating them with divider -----.
Code
#!/bin/bash
# concat script
if [[ $@ ]]
then
for i in "$@"
do
cat "$i" && echo "-----"
done
exit 0
else
cat 2> "Usage: concat FILE ...
Description: concatenates FILE(s) to standard output separating them with divider -----."
exit 1
fi