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

learn more… | top users | synonyms (1)

2
votes
1answer
315 views

Separate STDOUT noise from ncurses

I am trying to run an ncurses GUI application on an ARM board. I am running it using the serial console ttyAMA0 port. But when I run the ncurses program, the other processes running in the background ...
2
votes
1answer
2k views

redirection to file issues with nohup and pipe

For the following command: ssh -t esolve@hostname 'sudo nohup bash -c "ls > log 2>&1 &"' I always got error information: nohup: ignoring input and appending output to ...
1
vote
1answer
116 views

Standard I/O File Descriptors

I am new to Shell SCripting I code this $ ls -l 1> stdout.txt and I get the output as desired, 1> stdout.txt redirects the output from standard output to the file stdout.txt. I don't ...
0
votes
2answers
473 views

Redirecting stdin with stdout to file

So I have a program that takes in user input and outputs text based on the input. EDIT2: I want to create a script that runs a C executable and the script feeds the C program input from a file and ...
1
vote
2answers
435 views

Redirecting Multiple Commands as Input

What is the correct way to redirect the output of multiple commands as input for another command? e.g. $ command < (command2 | grep pattern)
4
votes
4answers
931 views

Getting stdin from a named pipe

What I am trying to do is run python in a terminal window and redirect it's stdin from a named pipe. Then I write to the named pipe in another terminal and have that command execute on python. ...
2
votes
2answers
102 views

What makes the shell interpret these redirects as follows?

Can anyone help me understand this seemingly odd behavior of how the shell parses the redirects..? $ cat > test.txt Line 1 Line 2 $ ls -i dummy.txt dummy2.txt ls: dummy.txt: No such file or ...
7
votes
2answers
10k views

Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1

Just looking for the difference between 2>&- 2>/dev/null |& &>/dev/null >/dev/null 2>&1 and their portability with non-Bourne shells like tcsh, mksh, etc.
8
votes
2answers
207 views

When should I use input redirection?

I used the following two commands to produce the same results:- [root@localhost ~]# grep line comments The line should start with a single quote to comment in VB scripting. Double slashes in the ...
2
votes
2answers
73 views

redirecting std output and std error

I have been trying to figure out the relationship between file descriptors. One thing I don't understand is, how is: ls -l /bin/usr > ls-output.txt 2>&1 different from: ls -l /bin/usr ...
3
votes
1answer
1k views

starting server with nohup and redirecting input, output

I have a init.d script that starts a python socket server. Because I want this to run as a daemon, I use nohup to start it. I also want to redirect stdout and stderr to a log file. My problem is ...
3
votes
1answer
230 views

Redirecting output in the shell, permissions

I have a question about permissions. Distro: Debian GNU/Linux 6.0.4 (squeeze) So I have a folder with a php script in it. Both folder and file are owned by User1 If I do this: php script.php I ...
3
votes
2answers
264 views

echo string >> file does not work

I wrote the following script: for filename in `find . -name '*'.cpp | grep $IN_REGEX | grep -v $OUT_REGEX` do echo "Output file is $OUTPUT_FILE" count=`git log --pretty=format: --name-only ...
1
vote
1answer
495 views

How to ssh on multiple ipaddress and get the output and error on the local *nix machine?

command="ls -lrt;uname -a;uname -o" for i in 10.38.227.229 10.38.164.103 do ssh auto21@$i "$command 2>&1" >> log #ssh -n auto21@$i "$command" 2> >> log done i am trying ...
4
votes
1answer
2k views

SSH causes while loop to stop

I have finally managed to boil down a problem I have been struggling with for a few weeks. I use SSH with "authorized keys" to run commands remotely. All is fine except when I do it in a while loop. ...
1
vote
2answers
168 views

Nested read fails

I have a list of filenames in a file and want to do let the user decide what to do with each. In bash, iterating over filenames is not trivial in itself, so I followed this answer: #!/bin/bash while ...
1
vote
2answers
124 views

run a command as different user with available sudo permissions

I want to run the below command echo 1000 > /sys/class/backlight/intel_backlight/brightness i cannot do it it like below beecause bash is the process that actually directs output to the ...
2
votes
1answer
123 views

Why can't I trim a file using `head`? [duplicate]

Given a file, foo.txt: 1 2 3 4 5 Say we want to change it to contain: 1 2 3 Why does head -n3 foo.txt > foo.txt leave foo.txt empty?
2
votes
1answer
492 views

How to wait for a subprocess used for I/O redirection?

Consider the following snippet of Bash script: exec 3> >(sleep 1; echo "$BASHPID: here") do-something-interesting exec 3>&- wait $! echo "$BASHPID: there" When executed, it produces: ...
2
votes
1answer
122 views

Why is it possible to refer to a closed stderr under bash?

I'd like to know why bash doesn't display an error message when we refer to a closed stderr. When it comes to other file descriptors, they have to be opened if we want to, for example, duplicate them. ...
2
votes
1answer
116 views

Stderr of piped shell scripts isn't always displayed

I piped my own shell scripts for some testing and accidentally noticed something strange. Namely, the stderr of those piped processes isn't always displayed on the screen. I simplified the scripts ...
12
votes
3answers
761 views

Practical use for moving file descriptors

According to the bash man page: The redirection operator [n]<&digit- moves the file descriptor digit to file descriptor n, or the standard input (file descriptor 0) if n is ...
3
votes
1answer
242 views

Significance of arrows symbols in duplicating/closing file descriptors under bash

I'm reading a book about Linux command line where author doesn't seem to follow the conventions in bash manual regarding arrows symbols used in redirection operations. Namely, he always uses left ...
4
votes
3answers
2k views

combine output from two commands in bash

Is it possible to combine output from these two commands? node ~/projects/trunk/index.js python ~/projects/trunk/run.py run Neither command exits so I'm not sure how to do this.
-4
votes
2answers
3k views

Redirecting the content of a file to the command “echo”

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... but I need to do it with ...
1
vote
1answer
95 views

How get program name that produced an IO error redirected to a LOG in a nohup command?

I have a program that executes other programs in the background. The main program would be programA, and the programs executed by the main one, would be program1a, program1b and program1c. I need the ...
3
votes
4answers
1k views

How to pipe the stdout to a file if the current command is already being piped through gzip

So I have this command I need to run then disown: innobackupex-1.5.1 --user=root --password=**** --stream=tar ./ | gzip - > /data/myfile.tar.gz How do I pipe any output to a file? adding ...
1
vote
1answer
99 views

Unsure about the behaviour of my script when writing to log file

I have a very simple ksh script and at certain points I want to write to a log file. I use the following commands in two places... print "Directory listing 1:\n" > ${LogFile} ll >> ...
2
votes
2answers
1k views

How to discard stderr in restricted Bash shell?

In my .bashrc there are a couple commands which redirect standard error to /dev/null, and this is not allowed within rbash: bash: /dev/null: restricted: cannot redirect output Is there some way to ...
13
votes
2answers
3k views

Redirect all subsequent commands' stderr using exec

I have a bash file that I need to redirect all output to one file, debug log as well as to the terminal. I need to redirect both stdout and stderr to the debug and log it for all commands in the ...
2
votes
1answer
250 views

How to copy the output of pacman-color into a file and to display the output with the colors in the terminal

Originally I used pacman, not pacman-color and I copied the output into a file and I displayed the output in the terminal with the following command : pacman -Syu | tee file.log Unfortunately, it ...
0
votes
0answers
49 views

Root user can't do everything? [duplicate]

Possible Duplicate: Redirecting stdout to a file you don’t have write permission on I'm quite new to Linux and I have a permissions questions. I'm using Linux Mint. If I go to /opt and do ...
43
votes
5answers
3k views

Can a command line program prevent its output being redirected?

I have become so used to do this: someprogram >output.file I do it whenever I want to save the output that a program generates to a file. I am also aware of the two variants of this IO ...
2
votes
1answer
490 views

How redirect input while process is running?

I have an interactive application that takes input from the keyboard. Whenever I run the application I always write the same things in the beginning. So I was thinking I could make a file with those ...
2
votes
4answers
154 views

store and execute redirection/piped command in script

How do you store, and later execute, a command with redirection and and a pipe? (And is it the pipe, or the redirection, or both, that's causing my problem?) I tried to print the urxvt version in a ...
2
votes
2answers
2k views

How to change the output redirection of a running process?

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 ...
9
votes
2answers
2k views

echo vs <<<, or Useless Use of echo in Bash Award?

By now the Useless Use of cat Award is very well known, and there's also a mention of a Useless Use of echo (not relevant for this question). I'm wondering if there should be a "Useless Use of echo in ...
8
votes
4answers
8k views

How to view the output of a running process in another bash session?

I have left a script running on a remote machine from when I was locally working at it. I can connect over SSH to the machine as the same user and see the script running in ps. $ ps aux | grep ...
2
votes
1answer
167 views

Why doesn't the output get redirected into the file?

have the following command line that outputs vmstat every second with a time stamp on each line via the perl script: vmstat 15 | /home/Beer/addtimestamp.pl > File_1 the contents of the ...
11
votes
2answers
638 views

Why is it that these two 'cat' commands result differently?

Let's assume that infile contains a specific text, and I were to execute the following set of commands: exec 3<infile cat -n <&3 cat -n <&3 The first instance of cat ...
2
votes
1answer
721 views

Redirecting syslogd Error Messages to an Error Log or to a Null File?

I have an old PowerPC laptop (old Mac Powerbook G4) that I am running a variant of Debian Squeeze on (MintPPC 9). I keep getting Kernel error messages when I am connected to a particular wireless ...
1
vote
1answer
1k views

Behavior of while loop and for loop in unix script

I am trying to read user and server details from file tempo.txt and then check the disk space usage of the file system on that unix account using another script server_disk_space.sh.But I am not able ...
0
votes
2answers
200 views

Why doesn't Bash accept `&>&3`, i.e. redirecting stdout and stderr to file descriptor 3?

Given the preamble, foobar function and invocations of it: exec 3>/dev/null function foobar { echo foo; echo bar >&2; } foobar >/dev/null foobar 2>/dev/null foobar ...
0
votes
1answer
105 views

Redirecting head output for update hosts file [duplicate]

Possible Duplicate: How can I make iconv replace the input file with the converted output? I'm writing a script to change the content of my hosts file but I got stuck on the head output ...
2
votes
1answer
388 views

Redirect all standard out for rest of script

I have a bash script that I want to redirect all the rest of the output into a file. #!/bin/bash # the part i dont know ${file} echo spo echo car cat ${file} output should be spo\ncar\n
2
votes
3answers
2k views

Count running processes using wc and ps

I tried using ps r > log | wc log but this returns Ambiguous output redirect.. Can someone explain why and provide another solution?
1
vote
1answer
104 views

What is the difference between who > lp and who | lp?

Why does the who > lp creates a file but who | lp leads the output to program lp? What is the underlying principle behind these two simple commands? Can somebody explain it with an example?
1
vote
2answers
3k views

How can I get vsftpd version into shell variable?

I want to get vsftpd version into shell variable. I can get it to console with ease: # vsftpd -version vsftpd: version 2.2.2 Also I can get a lot of other info into variable: # i=`bash --version ...
2
votes
2answers
170 views

Where to place a Bash shell redirection for a command? [duplicate]

Possible Duplicate: Order of redirections Apart from the standalone exec >&2 to redirect the current shell's input and output are there any behavioral differences in the following ...
7
votes
2answers
2k views

Does `Segmentation fault` message come under STDERR?

I ran an executable in bash ./code > log It shows occasional error messages on terminal whereas all printf statements go into log file. I re-run it like below ./code >& log Now, the ...