Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

echo to stdout and append to file

Tags:

bash

shell

echo

I have this:

echo "all done creating tables" >> ${SUMAN_DEBUG_LOG_PATH}

but that should only append to the file, not write to stdout. How can I write to stdout and append to a file in the same bash line?

like image 929
Alexander Mills Avatar asked Jun 15 '17 20:06

Alexander Mills


People also ask

Does echo print to stdout?

Introduction to the echo CommandThe echo command writes text to standard output (stdout). Some common usages of the echo command are piping shell variable to other commands, writing text to stdout in a shell script, and redirecting text to a file.

How do I append output redirection to a file?

When the notation > > filename is added to the end of a command, the output of the command is appended to the specified file name, rather than writing over any existing data. The >> symbol is known as the append redirection operator.

How do you append to a file in shell?

You can use cat with redirection to append a file to another file. You do this by using the append redirection symbol, ``>>''. To append one file to the end of another, type cat, the file you want to append, then >>, then the file you want to append to, and press <Enter>.


1 Answers

Something like this?

echo "all done creating tables" | tee -a  "${SUMAN_DEBUG_LOG_PATH}"
like image 139
mauro Avatar answered Nov 03 '22 01:11

mauro