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
39 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 ...
23
votes
2answers
19k views

/dev/tcp listen instead of nc listen

With a netcat listener like: nc -l <port> < ~/.bashrc I can grab my .bashrc on a new machine (doesn't have nc or LDAP) with: cat < /dev/tcp/<ip>/<port> > ~/.bashrc My ...
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
337 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. ...
3
votes
2answers
3k views

Pass argument to script, then redirect script as input to bsub

I am currently working with the bsub job submission system from Platform LSF. I need to submit job scripts, but I am running into a problem with passing arguments to the job script. What I need is as ...
4
votes
1answer
852 views

KSH styling text based menu using STDERR

Is it possible to format the STDERR in order to have a better looking menu using the select command? I have a simple select select oChoice in $(<tempMenu.menu) ; do case "$oChoice" in ...
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 ...
3
votes
1answer
2k views

How do I redirect all writes and reads from /sdcard/whatsapp/ to /sdcard/shared/ on android?

I am using bluestacks appplayer beta with a rooted android, I want to redirect all writes and reads from one directory to another, how do I do that? I have a terminal available to put commands in..
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 ...
36
votes
5answers
24k views

How can I make iconv replace the input file with the converted output?

I have a bash script which enumerates through every *.php file in a directory and applies iconv to it. This gets output in STDOUT. Since adding the -o parameter ( in my experience ) actually writes ...
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 ...
0
votes
2answers
2k views

How to redirect output of a 'xterm -hold -e' command

I know you can use tee to log output from a command in a terminal, e.g.: df -h | tee ~/log.txt However, how can I do this with a more complex command like this: xterm -hold -e program arg1 arg2 ...
8
votes
2answers
26k views

nohup: ignoring input and redirecting stderr to stdout

I am starting my application in the background using nohup as mentioned below - root@phx5qa01c:/bezook# nohup java -jar ./exhibitor-1.5.1/lib/exhibitor-1.5.1-jar-with-dependencies.jar -c file --...
3
votes
4answers
37k 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 ...
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 -...
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 ...
22
votes
1answer
2k views

Is there a way to redirect a program's output and still have it go to stdout?

Okay. If I wanted to redirect the output of a program to a file, I'd do something like this prog > file If I wanted to redirect both stdout and stderr to that file, then I'd do prog > file 2&...
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 ...
10
votes
2answers
4k 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 ...
16
votes
2answers
8k views

How to diff a file and output from the command?

Normally you would write: diff file1 file2 But I would like to diff a file and output from the command (here I make command a trivial one): diff file1 <(cat file2 | sort) Ok, this work when I ...
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 ...
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 ...
2
votes
1answer
207 views

GoAccess won't redirect its output as a CGI script

I've been pulling my hair with this script: #!/bin/bash echo Content-type: text/html echo "" goaccess -f /var/www/log/access.log -a | tee Which runs perfectly on the command line (generates HTML ...
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 ...
0
votes
0answers
101 views

How to enter username and password automatically in jrerun command?

jrerun is a command belongs to IBM Process Manager tool. This command will re-run the failed job. I want to create a script that re-runs automatically if it fails before 1 hour from start time. The ...
59
votes
5answers
38k views

How to redirect output of wget as input to unzip?

I have to download a file from this link. The file download is a zip file which I will have to unzip in the current folder. Normally, I would download it first, then run the unzip command. $ wget ...
1
vote
1answer
54 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 ...
6
votes
4answers
5k views

Sending the output from 'dd' to awk/sed/grep

I'm trying to approximate the computer's write speed using dd: dd if=/dev/urandom of=/dev/null bs=1K count=10000 which gives the following output 10000+0 records in 10000+0 records out 10240000 ...
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
59 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/...
45
votes
6answers
62k views

Using while loop to ssh to multiple servers

I have a file servers.txt, with list of servers: server1.mydomain.com server2.mydomain.com server3.mydomain.com when I read the file line by line with while and echo each line, all works as ...
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. ...
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
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 ...
2
votes
5answers
4k views

Why does the command shuf file > file leave an empty file, but similar commands do not?

I know this is sort of a duplicate of another question (Why this sort command gives me an empty file?) but I wanted to expand on the question in response to the answers given. The command shuf ...
71
votes
5answers
219k views

How to append multiple lines to a file with bash

I am writing a bash script to look for a file if it doesn't exist then create it and append this to it: Host localhost ForwardAgent yes So "line then new line 'tab' then text" I think its a ...
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 ...