0
votes
3answers
34 views

Redirect stdin to stdout

I've got a script, ex myscript.sh, and it has to redirect to stdout what it gets from stdin (like a cat). For example: myscript.sh < myfile.txt > myfile2.txt How to do this? Also, how can i ...
1
vote
0answers
58 views

How can I redirect OS X dtruss output when running with sudo?

I'm running dtruss on Mac OS X 10.9. Simple example is: sudo -c ls But I'd like to capture the dtruss output into a file. I saw something that suggests that I can do something like: sudo bash -c ...
1
vote
1answer
37 views

redirect one bash line to stdout/terminal vs log

I have a bash script where I'm redirecting output into a file for logging. if test -t 1; then # stdout is a terminal exec > $OUTPUT_FILE 2>&1 else # stdout is not a terminal, no ...
0
votes
2answers
88 views

Redirect two stdout to one stdin in Linux bash

I've got a C program that reads from stdin and does some operations. I am asked to enter information periodically (every 20 sec), and leave the user interaction the same while doing some tests. Is ...
0
votes
1answer
21 views

Bash return stderr of the first failed process

I need to run some commands and if any of those fails I would like to output JSON with it's stderr. I have the following line: OUT="$( (ssh internal "custom_script1" | custom_app1 2>&- | ...
1
vote
1answer
81 views

How to redirect ALL output from a command in Linux

I'm running Gentoo Linux. A program (equery) outputs a massive list of all the currently installed packages (equery list "*"). I want to find out which of them are unstable. Equery marks the unstable ...
2
votes
2answers
290 views

cat “input file is output file” while trying to combine multiple files into one

The plan was to collect all source lines of Java into one file, recursively: $ find . -name '*.java' | xargs cat >> all.java But there was an error: cat: ./all.java: input file is output ...
1
vote
1answer
128 views

Upstart and process substitution

So I want to use the following in my script stanza: forever -l >(tee $QW_LOG_DIR/webserver.log | logger -p user.info -t '[QW]') start webserver.js However, that doesn't work for at least two ...
0
votes
1answer
107 views

Bash conditional redirection when testing/debugging

What is the best way to conditionally do a redirection in Bash for testing and debugging purposes? In my scripts I add a debug option to show what would have happened effectively doing a test run ...
0
votes
1answer
237 views

Streaming log file contents (piping)

I am trying to understand how piping works and am stuck at this point. A log file is being streamed and its output is being piped to pigz. What I am trying to do is, redirect the pigz content to a ...
2
votes
1answer
1k views

How to redirect multiple bash commands to a variable AND screen?

I would like to capture a subshell's output in a variable and print it in the terminal screen simultaneously. Is it possible to do this by assigning the subshell to a variable and piping stdout and ...
6
votes
1answer
149 views

What is a good way to get back to the command prompt discarding STDOUT and STDERR

I often launch applications from the cli via e.g. command & to immediately get back to the prompt back. The downside of this is, that I still get STDOUT and STDERR. So I use command &> ...
1
vote
3answers
499 views

Obtain both merged and separated stdout and stderr

I am looking for a way to run a program Prog and end up with 3 files: The stdout of Prog The stderr of Prog Both stdout and stderr of Prog combined just as they would be on screen if no redirecting ...
1
vote
1answer
425 views

Redirect output of remote python app started through ssh to file

I have a python app in a remote server that i need to debug, when I run the app locally it prints some debug information (including python tracebacks) that i need to monitor. Im trying to redirect ...
1
vote
2answers
308 views

Nested Redirection in BASH

I have a scenario where I want to filter log files. To do this I am wanting to follow the last 10 lines or so of a log file and as new lines are read in, pipe them through an awk program and then ...
2
votes
3answers
4k views

Redirect stdout while a process is running — What is that process sending to /dev/null

I've run a command and redirected it's output via > /dev/null Now that it's been running significantly longer than I expected I want to see what it's doing. Is there a way to re-redirect the ...
2
votes
2answers
466 views

Redirect output of gnome-terminal to file

I have written a script which opens a new terminal using gnome-terminal. The output shown on gnome-terminal is correct. I want this output should be in some file. I have tried this: gnome-terminal ...
6
votes
2answers
5k views

How to redirect to stdin of a running bash shell?

Theoreticly, if I know the pid of the bash shell which is running, I can run a cat whose stdout is redirected to the stdin of that shell. It seems to be as if I type something on that shell. ...
1
vote
1answer
158 views

redirecting output from several piped commands

This works: find . -type f | xargs md5sum | sort This does not and gives several "md5sum: xyz not found" errors: ( find . -type f | xargs md5sum | sort ) >~/md5.txt Same for: find . -type f ...
25
votes
2answers
24k views

how do I echo $something >> file.txt without carriage return?

When I echo $something >> file.txt, a new line will be append to the file. What if I want to append without a new line?
2
votes
1answer
420 views

Scripted command line with redirection fails

The following works from the command line, but fails as script: gunzip -c /disk1/hadoop/gunzip_tmp/in/part-00006.gz >> /disk1/hadoop/gunzip_tmp/outfile.000 The following script lines: ...
1
vote
1answer
194 views

Pipe and watch piped output?

I want to make a shell-pipe like this: producer | analyser > report.txt and watch the output of producer while it is generating data (a big log-file) for analysis. How can I do that?
2
votes
1answer
169 views

How can I redirect input from file and then from terminal?

How can I run a program in bash in such a way that first it receives some input from a file, and then, as the file ends, it will receive input from terminal?
2
votes
1answer
918 views

Different output when redirecting

$ mysql -e 'select a,b from tablefoo' databasename yields +---+---+ | a | b | +---+---+ | 1 | 0 | | 2 | 1 | +---+---+ whereas $ mysql -e 'select a,b from tablefoo' databasename > file ...
9
votes
2answers
3k views

Is there a binary-safe “triple less than” <<< operator in bash?

This is a rather hypothetical question, so please don't ask me why I'd want to do this. Assuming that I have a variable GIF that contains binary data, and assuming that I cannot use the pipe | ...
0
votes
3answers
810 views

Redirecting Command output to file

This seems so simple when doing it from command line but I'm not able to accomplish it inside a script. I am trying to put output of following command into a text file: CMD= mysql -uroot -psecret -e ...
11
votes
3answers
4k views

What is the difference between &> and >& in bash?

What is the difference between &> and >& in bash? tldp did not mention the latter one. Is it really a redirection operator? Or does someone know a more complete tutorial?
3
votes
1answer
681 views

I/O redirection using cygwin and mingw

I have written a program in C and have compiled it using MinGW. When I try to run that program in Cygwin, it seems to behave normally (i.e. prints correct output etc.) However, I'm trying to pipe ...
3
votes
1answer
632 views

Linux: redirecting stdout and stderr

I want to write stdout to a file but also prints stdout and stderr. I tried using tee: prog | tee stdout.txt but this causes the printed stderr and stdout to be interleaved incorrectly, i.e. if the ...
1
vote
1answer
279 views

How to redirect standard out and standard error to a file, and standard error (only) to console at the same time

I would like to direct: Standard out to file. Standard error to the same file. Standard error to console (as well as file). I've seen this kind of thing: mycommand 2>&1 | tee test.txt ...
3
votes
1answer
1k views

copy (split?) stdout instead of redirecting it

In Bash, I'd like to redirect stdout to a file (>> mylog.txt) but also see the stdout output on the screen.. How can I do it with bash?
2
votes
1answer
573 views

Getting back to “stdin” after redirecting a file to a particular program

I need to achieve a particular effect using bash's redirection facilities. I know that I can redirect a file to some program's standard input: [user@host]$ application < file.txt The thing is, ...
0
votes
3answers
185 views

File redirection in bash

What's the difference between using > and >>? How can I use both < and > (redirection operators) in a single command?
15
votes
4answers
13k views

cURL: how to suppress strange output when redirecting?

I'm trying to print just the verbose sections of a cURL request (which are sent to stderr) from the bash shell. But when I redirect stdout like this: curl -v http://somehost/somepage > /dev/null ...
0
votes
1answer
299 views

How to stop redirection to /dev/pts/x

This is an examination senario. We have mulitple users logging into a RHEL-4 server using putty. These people are part of a same group. They are giving UNIX shell script exam. They are helping each ...
4
votes
3answers
4k views

How to ignore error messages in bash on Ubuntu?

I'm trying to show the number of lines, words and characters of all configuration files in /etc/*conf (with command wc). How can I modify the command (or commandline) to not view the error messages?
2
votes
1answer
157 views

Redirection: How did the extra word get in the file?

I was testing a script and wanted to create a small file with a bit of text in it so I typed the following and forgot to escape the space in the filename: echo "bob">other name When I did ls, it ...