io redirection is the process of changing where the output and input of a program originate

learn more… | top users | synonyms (1)

0
votes
1answer
28 views

How to redirect the warning message from command line to a log file?

I have a below loop that is used to check the active namenode in Hadoop cluster and if the first node is inactive it picks up the second. for (( i=0;i<$(($(wc -l < ...
0
votes
1answer
12 views

Cache not filling error when using mplayer to read from stdin

I have a program that's generating audio and I can't get mplayer to play it. I'm doing ./myprogram | mplayer - -cache 1024 -cache-min 30 -noconsolecontrols And I get the message Cache fill: X% (Y ...
2
votes
1answer
39 views

redirect split output

I split a gz file using gunzip piped to split: time gunzip -c file.gz | split -l 500 -d -a 4 - pref_ Which generates the following files: pref_0000 pref_0001 I'd like to pipe those files to zip ...
-1
votes
0answers
27 views

ngrep output redirection with -q option

when using ngrep in bash with -q option the '####' characters are gone and only the matches are shown but redirecting this to a text file results only in a empty file. sudo ngrep -q >> log.txt ...
0
votes
2answers
40 views

Can sed save its output to a file?

> can do it. echo "text" > file tee can do it. echo "test" | tee file Can sed do it without using either of the above? Is it possible to save the output of a sed command to a file without ...
1
vote
0answers
15 views

Redirect all output, including input prompts [duplicate]

I know that doing command &> /dev/null suppresses all output file descriptors. But I notice that it does not work for commands that request input from the user, most notably ssh: > ssh ...
2
votes
2answers
45 views

What does the < (left chevron / triangle bracket) do? [duplicate]

I am having a difficult time wrapping my head around this. I understand that the > (right chevron) is for redirecting the STDOUT of a program to a file, as in echo 'polo' > marco.txt will ...
0
votes
1answer
32 views

Redirect output of: yum repolist all

If you run the command: yum repolist all you will see there are basically four columns of data. repo id, repo name, status, install count. If however your run something like: yum repolist all > ...
0
votes
2answers
25 views

nohup with at the end <&- [duplicate]

nohup grunt server:debug >grunt.out 2>&1 <&- & I have a nohup command that ends with <&- . What does this direction do? Can some explain with pointers. I did search ...
0
votes
2answers
28 views

operate on different sections of stdin without intermediate file

Is there a simple way to do this with redirection or pipes without creating FILE1? I want to apply process2 to the body of the output of process1, without touching the first and last few lines. ...
8
votes
5answers
457 views

Is there a tool to dynamically redirect output to a new file on request

I'm currently redirecting the output of a monitoring tool to a file, however what I'd like to do, is to redirect this output to a new file on my request (using a keybinding), without stopping the said ...
0
votes
2answers
38 views

Why cant I overwrite a file with processed value?

This question prompted a thought I was not sure I understood well. I know that it is not possible or correct to use pipelines like cat myfile | grep -v mypattern > myfile due to how file handles ...
5
votes
2answers
31 views

What exactly happens if input and output file is the same?

Let's say that I execute following command: tr a-z A-Z < file > file There are two redirections: < file and > file. Both are processed before tr command and as far as I know, if there ...
0
votes
1answer
36 views

unzip without replacing original file and report to log

I want to write a bash script to decompress a file without overwriting the original one and redirect the operation result into a log file. I found an answer to the first part of my question at: How ...
8
votes
4answers
561 views

Bash program not executed if redirection would fail

In bash, I notice that if a command using redirection would fail, any programs which run prior to that are not run. For example, this program opens the file "a" and writes 50 bytes to file "a". ...
2
votes
2answers
315 views

How can I redirect the output of a child process?

I am running the following git clone command through sudo and bash and I want to redirect STDOUT to a log file: % sudo -u test_user bash -c "git clone https://github.com/scrooloose/nerdtree.git ...
2
votes
1answer
27 views

Unable to redirect stdout/stderr to log file [duplicate]

I have a script tmp.sh #!/bin/bash echo hello sleep 3 echo 3 I want to log the script running time (as well as script stdout) to a log file. user$ time ./tmp.sh >& log.tmp real ...
1
vote
0answers
29 views

Deleted file being written to by running process, can I recreate it? [duplicate]

I've started a long running process with nohup and redirected it's output to a log file Example: nohup ./bin/zkServer.sh start-foreground > /usr/local/myuser/logs/zkout.log 2>&1 & I ...
0
votes
1answer
34 views

How to generate a text report in Linux?

I have a command I'm using to find all of the *.xml files on our server. I'm using: find -type f -exec grep -il "xml" {} \; This is great, but there are maybe a thousand files like this on the ...
0
votes
2answers
50 views

How is redirection implemented?

Is redirection a concept of the shell, not of the OS kernel? How is redirection implemented in terms of system calls? Is redirection implemented similarly to pipe?
0
votes
1answer
29 views

Change a file while redirecting it as stdin input to a command

In Bash, while running mycommand < myfile, I modify myfile's content. What content of myfile does mycommand get? Does mycommand get the original content of myfile when i started running it, or ...
1
vote
2answers
80 views

Why is this script looping on the first line of the txt file?

#!/bin/bash usernameFile="/home/netadmin/username_list.txt" logFile="/var/log/netvpn-mag-archive/netvpn-mag-20160" while read -r line < $usernameFile; do if [[ "$line" != " " ]]; then ...
2
votes
1answer
25 views

Connect via telnet and doing certain operations

I'm trying to code a script where I can connect via telnet to another server and execute certain operations, but I'm having problems with the result of this process. The objective is to connect to a ...
0
votes
0answers
21 views

Emptying a log file getting updated with 2>&1 output redirection [duplicate]

I have a server which constantly writes outputs and errors to stdout and stderr. The command line I use for running my server is: Server options-list > log.txt 2>&1 & Now the problem ...
0
votes
2answers
50 views

Piping sed/grep output does not work

If I run the commands bellow, only out1 has output, the out2 and out3 are empty. # this is just to generate a self-signed certificate openssl genrsa -out /tmp/ssl.key 2048 openssl req -sha256 -new ...
1
vote
2answers
87 views

How to redirect STDIN of background process?

In my Ubuntu, i run java application in background. I use bash script to run it and now it looks like: nohup java -jar app.jar & exit 0 The problem that i want to be able to write an input ...
10
votes
1answer
808 views

Shell variable $_ not behaving as expected

What the reason the number of lines differs? $ head -n 100000 ./access.log > ./data/log.sample $ cat $_ | wc -l 1933424
0
votes
1answer
21 views

Archlinux'es pacman + tee == unclear console IO [closed]

I have a small issue with capturing the pacman's IO with the tee utility. I try this command line: pacman -S group-1 group-2 | tee pacman.log And there is an issue: when the pacman query which ...
1
vote
1answer
39 views

“time > time.txt” refuses to work propely

I just started learning Linux commands. I was experimenting with the > command, that, as far as I understand, makes the command before it write it's output to the file after the sign. This ...
0
votes
1answer
30 views

Redirection Error in Function [closed]

I'm trying to figure out why the code below doesn't work, and gives me an error Bad file descriptor. It is sort of a follow-up to this question as applies to the script I'm currently working on. ...
3
votes
2answers
82 views

Returning a String and Understanding Redirection and Output

I'm trying to figure out how redirects could be used to selectively output a string from a bash function which needs to print multiple lines to the terminal. I found an answer on this question at ...
1
vote
2answers
50 views

Difference between 1> and >

Is there any difference between (# comments taken from documentation) command > filename # Docs: Redirect stdout to a file. and command 1> filename # Docs: Redirect stdout to file ...
2
votes
1answer
29 views

Sending `time` command into text file [duplicate]

I want to get the result of time command into a text file but it's not working it only put blank space in the text file. I already tried this commands, A- $ x=`time` $ echo $x > log.txt $ cat ...
4
votes
1answer
68 views

File descriptors and redirect in bash

Can someone explain why this command works: gpg --enable-special-filenames --verify --batch \ <(curl -s https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.0.29.tar.bz2.sig) \ <(curl ...
4
votes
3answers
191 views

Trying to make sense of bash redirection syntaxes and their outputs

I'm new to Linux and trying to understand how redirections work. I have been testing various syntaxes for redirecting stdout and stderr to the same file, which don't all produce the same results. ...
0
votes
2answers
60 views

How can I clear/empty a file being piped to?

Say I have some process which pipes to a file: yes > foo I know want to clear/empty the file foo, but still want the process to write to the file, i.e. start filling the file again after ...
0
votes
1answer
62 views

avahi-daemon fails to start with “Failed to chroot(): Permission denied”. But only without stderr-IO-redirection

After a recent upgrate, avahi-daemon is not starting up anymore. Furthermore, the behaviour differes weather if I redirect stderr to a file or not. If I start avahi-daemon --debug with debugging ...
2
votes
1answer
40 views

redirect to a named pipe

I know the difference between > and >> when redirecting to a plain file. But is there a difference when redirecting to a named pipe (fifo)? Assume the namedpipe is a named pipe. Are the ...
3
votes
3answers
55 views

redirecting output of a command as if it was file input

I find myself always having to arrow up and going backwards through the command line to change one part of an earlier command that is pipped to a later grep or head or whatever command. For a crude ...
2
votes
1answer
33 views

Possible redirection bug in zsh 5x

[This post's title needs some work; suggestions welcome.] The following command produces different outputs in zsh v. 4.x and 5.x: { ( printf "X\nY\n" printf "WARNING: foo\nWARNING: ...
1
vote
2answers
68 views

shell stderr to /dev/null

I have PID file and I want to get PID number so this is what I am doing. [root@linux ~]# PID=`cat /usr/local/foo/var/run/foo.pid` [root@linux ~]# echo $PID 3414 sometimes this file doesn't ...
0
votes
2answers
186 views

Why we need to have 2>&1 in /dev/null 2>&1?

I saw in linux script there was a command argument > /dev/null 2>&1, I know it is to redirect the output to null, means silencing it. I also know about the numbering for 0,1,2 (STDIN, ...
0
votes
0answers
18 views

Redirect stderr to stdout and tee to file and check return value [duplicate]

I know how to redirect stderr and stdout to a file: curl -sSo file http://foo.bar >> log 2>&1 I know how to get stdout to appear on the console and in a file: curl -sSo file ...
0
votes
2answers
33 views

Output pings with time greater than 100ms to file with a timestamp appended

I want to save in a file every ping with a time greater than 100ms and append a timestamp to every line. Searching I have managed to get this: ping HOST | grep --line-buffered "time=[0-9][0-9][0-9]" ...
6
votes
3answers
674 views

Does the shell fork when I use built-in commands?

When I run the command type type, this gives me a result to standard output. So, now I try this command: type type > abc.txt It redirects the standard output to abc.txt. So, if this command ...
0
votes
1answer
35 views

using command line arguement with redirecting

#include <fcntl.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { int val; if(argc!=2) { printf("Usage: %s ...
-1
votes
2answers
47 views

Is the delimiter in here document seen and used by the program which takes it as input?

The format of here-documents is: <<[−]word here-document delimiter Is the delimiter seen and used by the program which takes the here document as stdin input? Or is the delimiter used by the ...
3
votes
2answers
118 views

Order between `nohup`, `&` and redirection?

What is the correct order between nohup, & and redirection, when using together? Why are other orders not correct? For example, $ nohup firefox& &> /dev/null $ nohup firefox ...
3
votes
1answer
86 views

Stdin input to a command with nohup

from http://www.gnu.org/software/coreutils/manual/html_node/nohup-invocation.html nohup runs the given command with hangup signals ignored, so that the command can continue running in the ...
0
votes
2answers
74 views

bash: tee eats newlines after exec

To output both stdout and stderr from a script to the console and to a log file, I’ve found a beautiful solution with tee: exec &> >(tee log.file) The problem is, that sometimes tee seems ...