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

How can I redirect output files to a specific directory/folder

Suppose I have an executable in Unix. Suppose the name of the .exe file is myExe and it takes two parameters. I did not create this executable, this is a freely available one. myExe generates 4 ...
3
votes
1answer
13 views

Pipe command output to Yad and also log the output to a logfile

Need to have the process of command typically an update to be shown using yad and at the same time log all the output to a given log file set up. This is what I have apt-get update | yad ...
2
votes
2answers
42 views

Is it possible to send a HEREDOC over ssh to a remote host from inside a script running locally?

I essentially want to run a script on machine A which will SSH into machine B, execute commands on B, and return the output to machine A. So I am creating a csh script to do this, hopefully, if it's ...
1
vote
0answers
28 views

Why the output is not written to log from expect script

I am trying to write the output of the netcat command including the command also to a file by logging into remote servers. But it is not writing. What am I missing ? #!/usr/bin/expect -f set user ...
0
votes
1answer
26 views

explain this shell command with redirection and pipe

I can understand the statements like. bzip2 --version >/tmp/list_right 2>/tmp/list_error bzip2 --version >/tmp/list 2>&1 But I don't understand the statement: bzip2 --version ...
1
vote
0answers
60 views

Sed regex printing into a file.txt

I'm connected to a MQTT stream, and I filter out the data by entering : mosquitto_sub -d -t +/# 2>&1 | sed -n "/PUBLISH/{s|.*\('.*',\).*|\1$(date),|;N;s/\n//;p}" into the Ubuntu terminal. ...
19
votes
6answers
605 views

How to tell if output of a command or shell script is stdout or stderr

Let us say I run a command or shell script, and it gives me output. Without knowing the internals of this command or shell script, how does one determine if is the output was from stderr or stdout? ...
2
votes
1answer
76 views

Set bash script output to the line that called bash script

I've looked for the greater part of two hours trying to see if I could find a way to redirect the output of a bash script to the line that called the bash script. The best example I can use to ...
2
votes
1answer
37 views

Capture console output from existing process(es) to file [duplicate]

We have a requirement to troubleshoot an existing system running Busybox, we have Telnet access. It would be helpful to log the system's console output (ideally the last n lines of it) to a file for ...
0
votes
2answers
28 views

Unix how to loop through directories, send output to another directory with base name of input file

I am an infrequent user of UNIX, I'm sure this will be fairly trivial for any regular user so I appologize for that. I have the following code: for file in /home/sub1/samples/aaa*/*_novoalign.bam ...
10
votes
3answers
796 views

What does `1>>` and `2>>` mean in a bash script?

I have the following bash script, from what I understand >> is used to append the output of a command to an existing file instead of overwrite, but what is it doing in this case? This script is ...
0
votes
1answer
53 views

Ambigous redirect done >$2

I have finished my bash script but I am still getting two errors. I've also searched for related issues but none worked: #!/bin/bash avem_element () { local e for e in "${@:2}"; do [[ "$e" == ...
7
votes
2answers
264 views

How do redirection in a symbols work in a sequence?

I have file1, file2, file3. file1 contains 1 file2 contains 2 file3 contains 3 I use command cat file1 > file2 > file3 Results in: file1 1 file2 (contains nothing) file3 1 Why ...
0
votes
2answers
34 views

redirect output from interface?

I am echoing an AT command to a modem interface (/dev/ttyUSB3) and the command runs successfully. For instance the below command works and has an output of OK: echo -e "ATZ\r" > /dev/ttyUSB3 I ...
0
votes
1answer
49 views

“Sudo” prefixed command doesn't work; without sudo does.

I suspect this has been answered before, but I don't know what this is called, so I can't really search for it. How come this works : $ grep H=p <(udevadm info /dev/ttyUSB0) E: ...
4
votes
2answers
173 views

Appending works without >> when redirecting standard output and error

I have a file test.txt and have no file named test. When I tried ls test test.txt > new 2>new I was expecting new to be overwritten since >> is not used. But in the output file I got ...
1
vote
1answer
55 views

Correct syntax to avoid bash 'ambiguous redirect' message

I am trying to execute a command which accumulates stdout into an existing file and sends the error messages to another using the command below. commmand >> /home/user/accumulate_output.log ...
1
vote
2answers
90 views

Multiple File Redirection with awk and find

I have some files in a directory. And I want to add some lines at top and end of file using awk. Example: My awk command: awk 'BEGIN { print "line1\nline2" } { print $0 } END { print "line3\nline4" ...
1
vote
1answer
82 views

Redirection. What is “<>”, “<&” and “>&-”?

"<>" This operator I saw few months ago on the one site, but I don't remember what does it mean. Maybe I'm wrong and ksh has no "<>". "a<&b" I know that this operator merge input stream ...
4
votes
1answer
105 views

Change the status of the keyboard leds, from within an X session, without root access

I am trying to force the capslock led on. xset does not work for me, so I am trying to use setleds. In a graphical console, this command returns: > LANG=C setleds -L +caps KDGKBLED: Inappropriate ...
3
votes
1answer
95 views

How do I come by this pty and what can I do with it?

It seems that a simple shell redirect from /dev/ptmx gets me a new pseudo-terminal. $ ls /dev/pts; ls /dev/pts </dev/ptmx 0 1 2 ptmx 0 1 2 3 ptmx It disappears as soon as the process that ...
3
votes
5answers
276 views

Awk - output the second line of a number of .dat files to one file

I have searched through previously asked questions and can't find an answer to what I am trying to do. note, I am new to linux. I have multiple files something like: (in reality i have 80) file1.dat ...
13
votes
6answers
1k views

Is there another simple way to append line to end of file other than `>>`?

Recently I'm echoing short sentences to a tree_hole file. I was using echo 'something' >> tree_hole to do this job. But I was always worried of what if I mis-input of > instead of >>, ...
0
votes
0answers
16 views

Using `perf` repeatedly with file input

perf can be used to analyze the performance of a program. Say you want to test the performance of a program prgrm, with input from a file, you can run: perf stat prgrm < inp.dat Now when you ...
1
vote
1answer
49 views

Output Redirection

I am using the tee command to output the compilation errors of a program into a file along with the terminal. gcc hello.c | tee file.txt This is the command I have used. The compilation errors are ...
6
votes
2answers
928 views

What does `date 2&>$0` do?

I am looking at a co-workers shell code and I saw this: date 2&>$0 I know what date does, but what's 2&>$0 doing? He's out for a while, so I can't ask him what this part was about.
0
votes
1answer
66 views

Redirecting Standard Output And Standard Error to One File [duplicate]

I have come to understand that we have two methods of redirecting both stdout and stderr to the same file. The first method is: ls -l /bin > ls-output.txt 2>&1 As the author of this book ...
2
votes
2answers
161 views

output both stderr and stdout on console and store them in a file at same time

may I output both stdout and stderr on console screen and store one of them into a log file? I write a test shell script: #!/bin/sh echo OUT! >&1 echo ERR! >&2 I can output both of ...
2
votes
1answer
78 views

Behaviour of 1>&0 in bash

So I am trying to learn more about file descriptors and their redirections. At the moment I am exploring an edge case of doing 1>&0 and I cannot quite understand what is happening there. $ ...
1
vote
1answer
87 views

Redirection differences between &> >& and 2>&1

On this SO thread and a few other threads I have seen the following commands for redirecting stdout and stderr to a file. Are they all equivalent? Is there any difference between them? command1 ...
0
votes
1answer
33 views

How do I suppress all email notification from cron for particular job?

I am scheduling the following shell script #!/bin/bash (echo open mailserver.nowhere.local 25; sleep 1; echo EHLO; echo quit)\ | telnet | grep "?Invalid command" if [ $? -eq 1 ]; then ...
1
vote
1answer
46 views

Controlling the terminal while in the middle of a pipe [duplicate]

Say I have 3 commands linked through pipes: A | B | C I would like B to output error messages to stderr and some progress to the terminal. If stderr is the same as the terminal, then that is easy: ...
3
votes
1answer
73 views

How to redirect output while using a here document

How to redirect the output of below command in shell into logfile. sqlplus -s "/nolog" <<EOF conn / as sysdba @?/sqlpatch/19282021/postinstall.sql exit; EOF
2
votes
1answer
96 views

How does ssh prompt for a password when all input and output is redirected?

I don’t actually need to run the command below, and I am aware of ssh keys if I did want to log in without typing a password. I would just like to know how ssh seems to circumvent my file redirection. ...
0
votes
5answers
58 views

Is there a way to do a “full file buffering” inside a chain of piped commands?

Very often I do simple operations on a file, for example: cat file1.txt|sed -r 's/^ *//' to remove spaces at the beginning of the line. If I want to overwrite the file, the only way I know is: cat ...
1
vote
0answers
57 views

redirecting output of running background job in bash

in bash I have some jobs running, in background. They are always producing random irrelevant error messages that pollute the terminal. I am not always so prompt to start them with the 2>&1 > ...
3
votes
1answer
71 views

Problem with getting interactive input in while read loop

I was doing something like the following minimal example: #! /bin/sh # $1 = file containing list of files to sync # $2 = source dir ; $3 = target dir cat "$1" | while read f do cp -i "$2"/"$f" ...
1
vote
0answers
39 views

Capturing data from a Fluke 1620a via Bash /dev/tcp file descriptor

I am currently trying to develop a script that will connect to a Fluke DewK 1620a Themo-Hygrometer and pull the current temperature and humidity readings from the device. While these devices have a ...
2
votes
3answers
81 views

Using a command's output to determine the name of the file to redirect output to

I want to run smartctl -a, and use the device serial number from that output as the name of the file to store the output in. I know this can be done by invoking smartctl twice, and slicing up the ...
0
votes
0answers
107 views

how to route traffic on port to ip:port on linux?

I'm trying to route all traffic on port udp 5000 to udp 192.168.0.1:12333 with the following command: $ iptables -t nat -A PREROUTING -p udp -m udp --dport 5000 \ -j DNAT --to 192.168.0.1:12333 ...
7
votes
4answers
359 views

output to file, then use file for input

Is there a shorter way of writing this? Basically output a command to a file, then use the file as input for the next command. I also want to keep the file to view afterwards. cmd1 > verylong.txt; ...
1
vote
2answers
347 views

Redirect stdin and stdout to ports

I'd like to take a program P that reads from stdin & writes to stdout, but connect it to nc or whatever such that it reads from a certain port and outputs to another port. # The reading is easy, ...
3
votes
2answers
158 views

Syntax error: word unexpected on io redirection on file descriptor ≥10

I have the following shell script on debian 7: #!/bin/sh case "$IFACE" in lo) # The loopback interface does not count. # only run when some other interface comes up exit ...
1
vote
2answers
44 views

Capturing data from a Fluke 1620a via netcat

I am trying to pull temperature and humidity data from Fluke DewK 1620a thermo-hygrometers and write the temp/humidity readings to a log. I can connect to the device via netcat with a simple 'nc ...
1
vote
1answer
36 views

redirect to the same file as the source file processed by the command [duplicate]

Redirection is not allowed here. Is cat not allowing? But isn't redirection independent of any command running with it? $ cat bk > bk cat: bk: input file is output file Why does the following ...
-1
votes
3answers
62 views

what is the use of '<<' redirection? [duplicate]

I am looking for an example of << redirection because i don't understand it well. I know < is for sending the contents of specified file to be use as standard input like : cat < file.txt ...
3
votes
3answers
72 views

How can I base the file name off of an already existing variable?

I'm using this to delete lines that don't match a pattern: $ egrep "pattern1|pattern2|pattern3|pattern4|pattern5" But now I need to do it automatically, so I'm setting a variable like this: $ ...
4
votes
3answers
381 views

Hide ouput of bash while running automated script.

I have a couple of scripts in my bash file, that should do certain tasks, say like ... #!bin/bash yum -y update service restart nginx yum install atop cat /var/log/somelog.log > ...
1
vote
2answers
157 views

Combination of echo, pipe and cat

I have a file name called temp.csv in my script one of the intermediate step is echo "some info" > final.csv | cat temp.csv >> final.csv at times the file final.csv is created without ...
1
vote
2answers
171 views

double grep on tail -f gives no output

If I follow a file somehow like this: tail -f /var/log/syslog|grep s I see all lines containing an "s" Why does this not give any output, if I grep it again to the same "s"? tail -f ...