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
19 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
40 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
57 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
46 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
44 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
24 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
40 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
13 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
70 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
36 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
348 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
88 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
64 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
26 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
28 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
59 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
67 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
312 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
63 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
113 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 ...
0
votes
3answers
74 views

Pipe/redirect a group of commands

I currently use the following setup to redirect the output of multiple commands: echo "Some normal commands" ( echo "Error: something happened" echo "Warning: this incident will be logged" ) >> ...
27
votes
2answers
2k views

How does `cat <> file` work?

cat < file prints the contents of file to stdout. cat > file reads stdin until Ctrl+D is detected and the input text is written to file. cat <> file, at least in my version of Bash, ...
0
votes
1answer
131 views

grep: input file 'X' is also the output

I use ubuntu 14.4, and attempt to redirect the output of grep command to a file, but I keep getting this error: grep: input file 'X' is also the output I've searched for this issue and just found ...
3
votes
3answers
135 views

Dash equivalent of self-redirection of script output

In Bash you can redirect all future stdout output of the currently running script. For example with this script, exec > >(logger -t my-awesome-script) echo 1 echo 2 echo 3 This will end up in ...
0
votes
0answers
46 views

Why is a here-string command substitution considered as a single line?

I'm experimenting with while read syntax and there is a thing I don't understand. The most basic scenario which reproduces the problem is the following: a bash script a.sh calls another script b.sh ...
5
votes
1answer
273 views

Why does “cat /tmp/out1 > /tmp/in2 &” appear as “bash” with the “ps” command?

Consider: mkfifo /tmp/out1 mkfifo /tmp/in2 cat /tmp/out1 > /tmp/in2 & When I run ps it appears as bash in the CMD section. Why?
1
vote
1answer
56 views

Pipes & redirection binding precedence with disjuncts, conjuncts etc?

I know of the relative binding precedence of operators ‘;’, ‘&’, ‘&&’, or ‘||’ http://www.gnu.org/software/bash/manual/bashref.html#Lists but when pipes come into the picture along with ...
2
votes
2answers
50 views

saving the output of command line in a text file?

I am using the following command line to analyse data: unpackdcm -scr ${in} -targ ${out} This command is printing on the screen status and description about the progress in the job. In order to ...
1
vote
1answer
46 views

Redirect output to stdout and pipe to a binary

I have a nice PS1 line in my .bash_profile, and I want to copy it to another machine. So I want to view it AND copy it to my clipboard. I can't figure out how to string the commands to do this ...
3
votes
2answers
130 views

How can a bash script write its standard output from within a pipeline? [duplicate]

I have a bash script that calls a function. The function, amongst other things, executes a pipeline that sinks its output. To simplify it, here is a contrived example: #!/bin/bash func() { ls "$@" ...
0
votes
1answer
33 views

UNIX stdout redirection

I've written a script and I want to direct the console output to a file, so I use this command: ~/simplesim-3.0/sim-cache -cache:dl1 dl1:1:64:2048:f -cache:il1 il1:1:64:2048:f \ -cache:il2 dl2 ...
0
votes
3answers
60 views

Redirect stderr and stdout to another file descriptor

exec 6>&1 will copy file descriptor 1 onto 6. But how can I copy both stderr and stdout (1 and 2)to file descriptor 6 ?
4
votes
3answers
87 views

Time required to do pipe output to head/tail [duplicate]

There are lots of txt files in a directory. If I do time wc -l *.txt | head it takes real 0m0.032s user 0m0.020s sys 0m0.008s If I do time wc -l *.txt | tail it takes real 0m0.156s ...
2
votes
1answer
119 views

Writing to an interactive prompt

I’m using the ftp command line tool and want combine scripted input with user input. With only user input the prompt looks like this: ftp> But when I try to insert some input with a script, like ...
1
vote
1answer
22 views

ag output appears different in the terminal vs when piped to a file

When I run the ag command to search text files, I get output that looks like this on the command line (full results not shown): ❯ ag dependency 140317155505.md 27:The Bundler dependencies API ... ...
-1
votes
1answer
64 views

Redirect a directory as input to a script and output to a file

I want to use a directory name as a parameter for a pre-made script. Then the output goes into a newly made file in the home directory. It involves pipe/redirection. How do I do that? read dir $dir ...
5
votes
2answers
265 views

How to capture ordered STDOUT/STDERR and add timestamp/prefixes?

I have explored almost all available similar questions, to no avail. Let me describe the problem in detail: I run some unattended scripts and these can produce standard output and standard error ...
0
votes
6answers
68 views

What are some practical uses of STDIN redirection? [closed]

I am having a very difficult time trying to think of a single practical use for STDIN redirection. cat < /etc/passwd is an example of STDIN redirection, but it is silly in the same way as a useless ...
7
votes
4answers
316 views

Can I specify a redirected input before a compound command?

Bash lets you specify a redirected input before a command: $ <lines sed 's/^/line: /g' line: foo line: bar Bash also lets you redirect input to a compound command like a while loop: $ while ...
1
vote
2answers
141 views

How to grab output from command in shell script [duplicate]

I'm trying to write a shell script in RHEL which will execute grub-md5-crypt and the user will type their password. Now the problem is how can I grab the encrypted md5 hash displayed to the user in ...
2
votes
2answers
68 views

Should I use piping or redirection for input to 'sort'

I want to do awk -F "," '{print $1 }' inputfile1.txt | sort -u > distinctOutput.txt Is this good performance-wise ? Or should I redirect / use a temp file since I think it is better to make sort ...
1
vote
1answer
46 views

fuser output looks ambiguous

I am using fuser the output is like this: $ fuser / /: 1354rc 1362r 1370rc 1371rc 1395rc 1399rc 1403rc 1410rc 1414rc 1428r 1451rc 1458rc 1470rc 1472rc 1477rc 1480rc ...
-4
votes
1answer
73 views

UNIX homework question regarding piping output, I don't understand what it's asking?

Basically, I need to come up with a command that sends the contents of a file xxx into a program yyy, then the output is piped to the input of another program zzz, where the output is appended to a ...
11
votes
2answers
225 views

Why does cat x >> x loop?

The following bash commands go into an infinte loop: $ echo hi > x $ cat x >> x I can guess that cat continues to read from x after it has started writing to stdout. What is confusing, ...
1
vote
1answer
266 views

How do I Nohup an interactive shell-script?

My Script is having 2 command-line arguments and then just couple of questions, after these questions the script will run for itself, I'm able to pass the command-line argument by just doing, ...
1
vote
2answers
142 views

Process substitution with input redirection

I am trying to understand input redirection in combination with process substituation. I am using bash 3 An example with tr is the following $ tr "o" "a" <(echo "Foo") tr: extra operand ...
1
vote
1answer
43 views

Cannot redirect output from sed

I'm piping output from clock through sed to remove leading zeroes from numbers. It looks like this: clock -sf 'S%A, %B %d. %I:%M %P' | sed 's/\b0\+\([0-9]\+\)/\1/g' That works fine and produces the ...
0
votes
1answer
57 views

Bash STDERR still appearing after redirection [closed]

I am trying to parse the output of yum check-update in Bash 4 (Red Hat) and want to skip the first line that states: 'This system is not registered to Red Hat Subscription Management. You can use ...
5
votes
2answers
471 views

Is there any way to read lines from command output?

I have a pre process command to output a file ./preprocess.sh > preprocessed_file and the preprocessed_file will be used like this while read line do ./research.sh $line & done < ...
1
vote
3answers
259 views

How to send a output of unix command from one server to another server?

How to redirect the output of a unix command from one server to another server. I should be able to send the unix command's output from server-1. Then I should be able to receive the output in ...