I came across and unexpected behavior with redirections in tcsh.
Is there a way in Windows 7 cmd shell to redirect the stderr to stdout while keeping the stderr stream intact?
For example, I have a program that outputs to stderr and stdout the following message
TO STDOUT
TO STDERR
I want to have two files stderr.txt and stdout.txt with the following content
stderr.txt
TO STDERR
stdout.txt
TO STDOUT
TO STDERR
Is this possible?
I've never really thought about how the shell actually executes piped commands. I've always been told that the "stdout of one program gets piped into the stdin of another," as a way of thinking about pipes. So naturally, I thought that in the case of say, A | B, A would run first, then B gets the stdout of A, and uses the stdout of A as its input.
I have a script a.sh, which has an sftp command:
echo "Starting to sftp..."
sftp xxx@xxx.xxx.xxx.xx << END_SCRIPT
ls
mput *.csv.gz
bye
END_SCRIPT
echo "Sftp successfully."
If I run it interactively, the log output from sftp is shown. However, if I set it in a crontab and redirect the stdout to a file using >, there will be only the output from the two echo statements.
Trying to do :
help:
@echo "you must $(call red_text,clean)"
where red is defined as
red_text = $(shell tput setaf 1; echo -n "$1"; tput sgr0)
This prints "you must clean", where word "clean" is printed in red.
The problem is when output of make is piped (e.g. to less).
In this case I should not use colors, but rather print the $1.
I need to update red_text to handle the case.
I have a file named my_file.txt whose content is just the string "Hello". How could I redirect its content to the command echo?
I know I have the commands less, cat, more...
Synopsis
echo [-neE] [arg ...]
Description
echo outputs it's args to stdout, separated by spaces, followed by a newline. The return status is always 0. If the shopt option xpg_echo is set, Bash dynamically determines whether echo should expand escape characters (listed below) by default based on the current platform.
I know how to redirect output and how to suppress them in bash. Now, suppose I accidentally forgot to append the output redirection part to the command (e.g. 2>&1 or > /tmp/mystdout) and my background process is already running for a while, can I still change to where stdout and stderr are being written to?
As part of a continuous delivery pipeline I'd like to install an msi on a given machine.