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
33 views

Capture stdout from ssh session to local machine

I am having to put together a script that will ssh into devices to run a command such as "show running-config" and save the output to a file on my local machine. I have done similar tasks like this ...
1
vote
2answers
40 views

Redirect tty to standard

I have a script which outputs things on /dev/tty, so it cannot be outputed into logs or anything by default. I would like to capture ALL outputs of the given script from another script to store it to ...
-1
votes
4answers
40 views

Extract files from a directory and save the files' names and sizes in KB in a CSV file

I want to retrieve all the .log files from the directory /var/log, store the results in a csv file along with each log file's respective file size in kB. I started by getting the files using find: ...
3
votes
1answer
103 views

Redirection after a process has started [duplicate]

Say I have called firefox from the terminal with firefox, and I got back to the terminal. I can now suspend the process with ctrl-z, and resume it in the background with bg. However it will continue ...
2
votes
1answer
64 views

Shell: mutual piping of STDIN/STDOUT of two commands [duplicate]

When we run this with a POSIX shell, $ cmd0 | cmd1 STDOUT of cmd0 is piped to STDIN of cmd1. Q: On top of this, how can I also pipe STDOUT of cmd1 to STDIN of cmd0? Is it mandatory to use ...
2
votes
4answers
65 views

Redirect script stderr & stdout to a file, but keep stdout to tty as well?

In my script, I currently have: exec > >(tee -a /tmp/history.log) 2>&1 This writes both the stderr and stdout of all commands to both the log file and the tty. Unfortunately, this ...
3
votes
5answers
339 views

When I redirect the output of ls to a file, the filename is included in that file. How can I avoid this?

Observe: $ ls $ ls > list $ cat list list This appears to indicate that when ls is executed that the redirection into file list has already begun and the list file is already created. A fine ...
1
vote
1answer
28 views

How can I capture screen output to a named file on a command by command bases?

I am running commands remotely stuffing them into screen commands via SSH. Rather than type directly into the terminal displayed, I use remote SSH commands which are run by clicking a button in a GUI. ...
14
votes
2answers
1k views

How do programs output to elsewhere than STDOUT/STDERR? How to avoid it?

Apparently I don't know all the output destinations that are available for use. I know about stdout(&1) and stderr (&2). However, after redirecting both descriptors, I sometimes still get some ...
4
votes
2answers
64 views

What's the difference between “>&1” and “>/proc/self/fd/1” redirection?

I'm working on some script that being run by rc.local at startup, and I noticed that output redirection works quite strange. If I write something like echo "foo" >&1, it ends up in syslog, and ...
-1
votes
1answer
61 views

How to cat file from output of other command?

If I do: perldoc -l WWW::Mechanize I get the following output: /usr/local/lib/perl5/site_perl/5.16.3/WWW/Mechanize.pm How can I, in one line, print to the screen the contents of the file given ...
0
votes
1answer
22 views

Replace value in a table

I have some tables for which I need to replace a field that has a random position in each table. For information, the table are semicolon separated fields and I would like to replace the field "datum"...
1
vote
1answer
51 views

Capture all output, error, warning and their appearance order of linux's command

In linux we can redirect stdout and stderr or both of them to files. For example: Redirect stdout and stderr to two files: command 1>out 2>err. By this way, we can separate output and error in ...
1
vote
2answers
47 views

Log the output of Expect command

I have made the below expect script and I need to log the output of that script. SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' ` if [ -n "${SOURCE_FILE}" ] ...
5
votes
3answers
73 views

How to make a redirection loop

This one is mostly for academic reasons. ;-) Consider the following Bash statement: foo | bar This executes two processes, foo and bar, such that the standard-out of foo is connected to the ...
0
votes
2answers
63 views

Suppress warning messages from MySQL in shell script but allow errors

My log files are getting dumped with following message while running shell scripts using some underlying MySQL commands. Here is the message: "Warning: Using a password on the command line ...
2
votes
0answers
33 views

Trap ctrl c not working as expected

I have a code that looks like this: { trap cleanup SIGHUP SIGINT SIGTERM function executed() { if [ ${1} -ne 0 ] then echo "Failed!" cleanup ...
2
votes
1answer
41 views

redirect output of command to /dev/null

I run the following line from my bash script in order to run the script /usr/run.pl on remote machines xargs -P "$numprocs" -I '{}' -n 1 -- perl -e 'alarm shift; exec @ARGV' -- "$timeout" ssh -...
1
vote
1answer
15 views

Ldap error doesn't redirect to file

I'm running a loop querying ldap server for a single dn every time, just to see if it's running okay. I want to output both the successful and unsuccessful responses to a file and while the former ...
2
votes
1answer
45 views

One of several file-append redirections of “python --version” is repeatably 'overlooked' by bash, but the others aren't [closed]

Why is bash consistently passing one, specific redirected output from python --version to the console rather than appending to file, while every other output is redirected properly? I am developing a ...
0
votes
1answer
37 views

Redirect keyboard input to unfocused program

I'm looking for some help with a computing issue. I'm running Openbox 3.5.2 on Raspbian/Pi3 and a single monitor. I want to have one program focused and in fullscreen while the keyboard outputs to ...
5
votes
0answers
51 views

Piping the output of a bash script after redirecting stderr

because of the way my hoster does things I have to use a system for services. This service has a run file which it executes and pipes into a second run file. But I use a (given) python package that ...
1
vote
0answers
18 views

How to limit/monitor a cgroup process's blkio when process has output redirection

I have some questions on cgroup blkio controller. I want to limit the IOPS on a specific process. This process uses IO redirection to write the stdout contents into a file. I tried to put the ...
1
vote
1answer
55 views

Redirect bash variable into netcat

I am attempting to write a bash loop that passes a bash string into netcat. The command that I execute is: nc -nv [ipaddress] [port] << EOF 10000 EOF I am writing a bash loop to perform this ...
2
votes
1answer
33 views

How do I discard unwanted fail messages from an ssh command?

I'm trying to avoid printing messages to the console received when a lun is not found during an ssh command. SSH is to a NetApp filer. Command is being run on a Solaris 10 host. Here is some of the ...
1
vote
2answers
60 views

Bash redirection doesn't work for SQLite command

Bash allows for piping to stdin from another command in this way... $ ls /bin/aud* | cat /bin/audacity /bin/audiocompose /bin/audiosend ... ...and this way as well: $ cat <(ls /bin/aud*) /bin/...
0
votes
1answer
22 views

Redircting stdout to file, but duplicating stderr to both file and terminal [duplicate]

Redirecting stderr to file and duplicating stdout to both file and terminal is easy: $ prog 2>error.log | tee output.log tee will duplicate stdout, printing it to both terminal and output.log. ...
0
votes
0answers
24 views

Bash Script to start a service on Ubuntu Linux 16.04

Does the following Ubuntu 16.04 bash script command: exec /usr/lib/mono/4.5/mono-service.exe \ /home/frank/Debug/My_Camera_Recorder.exe "$@" >& /dev/null start the My_Camera_Recorder ...
1
vote
1answer
57 views

stderr not redirected to stdout

I run a TACACS+ server which sends debug information to stderr. As I would like to grep specific data from this debug information, I redirected stderr to stdout: tac_plus -f /usr/local/etc/tac_plus....
0
votes
1answer
41 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 < $LOCAL_DIR/'tempip.txt')/3));...
0
votes
1answer
35 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
56 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 ...
0
votes
2answers
72 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
83 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
71 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
33 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
32 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
491 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
40 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
35 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
46 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
607 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
443 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 /home/...
2
votes
1answer
48 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 0m3....
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
56 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
59 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
31 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 ...