A Unix pipe connects file descriptors of two processes. A pipe is created with the POSIX pipe() function declared in . Shells provide pipe creation between processes using "|".

learn more… | top users | synonyms

3
votes
2answers
41 views

Can I `join` against a command?

I find join pretty useful. It lets you join file1 against file2 on key fields. Is it possible to do so dynamically against the results of a command, like: join -1 1 -2 1 file1 'curl http://example....
8
votes
4answers
878 views

Why can't I pipe `pwd` to `open` on macOS?

This is macOS specific, but seems too unixy to go in the Ask Different community. In Terminal, I can pwd, copy the result, and type open and paste the result and the folder will open in the Finder, ...
1
vote
1answer
33 views

cat into stdin then pipe into program keeps forked shell open, why?

I'm not sure what's going on but I've been trying to understand what is happening with the input and output. So here is my program. #include <stdio.h> #include <stdlib.h> int main(){ ...
1
vote
2answers
26 views

Alternative to process pipeline

Shell script on which I am working is having one SQL query which fetches multiple column and multiple rows from DB: get_names() { $ORACLE_HOME/bin/sqlplus -s usr/pwd <<EOF SELECT id,...
2
votes
1answer
66 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 ...
0
votes
1answer
28 views

Order of signals: SIGPOLL and SIGCHLD

I spawn a child process and connect to it with a pipe. I configure the pipe to send SIGPOLL on data available by fcntl I_SETSIG. The child sends some data over the pipe and then terminates. Can I ...
1
vote
1answer
22 views

Systemd: pipe input to daemonized server?

So I have a server that I can run from a bash terminal using e.g. java -jar spigot.jar which will send output to stdout (I believe), and thus be printed to the terminal screen. To stop the server ...
0
votes
1answer
31 views

`uniq` is not realtime when piped

When I run for i in {1..2000}; do sleep 0.1 && echo $(netstat -s | grep -i syns); done | uniq i can see in realtime when expression $(netstat -s | grep -i syns) changes. But when I want to ...
-1
votes
1answer
62 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 ...
2
votes
1answer
59 views

how best to send the output of a find + exec command to a pipeline?

I would like to understand how to correctly send the output of a find + exec command to a pipeline for further processing. i.e. how can we (1) select a group files (2) perform some operation on the ...
1
vote
1answer
21 views

Pseudo-terminals vs. a pair of pipes

Why are pseudo-terminals a seperate feature on Unix-like systems? What makes them superior to a pair of pipes or FIFOs for implementing terminal emulators?
1
vote
2answers
45 views

pipe ls to grep (lines vs. “items”)

Consider the following command: ls dir1 dir2 file1 x1 x2 y2 when this output is piped into e.g. grep each file/directory is processed as an 'item'. ls | grep f file1 So obviously there is a ...
0
votes
0answers
27 views

AH00493: SIGUSR1 received. Doing graceful restart

My Apache is restarting a few times a week. I use cPanel and I have "piped logging" enabled (which should prevent restarts). However, how can I know what is sending SIGUSR1 signals to Apache at ...
0
votes
1answer
22 views

Piping to mail results in new lines instead of overwritten lines

We are running maldet on several servers and we pipe the output of the cronjobs to a mail address to check the results. For 9 servers this works well but with the 10th server the output is different. ...
1
vote
1answer
38 views

What does '-t' do in mv command? Example below

ls -lrt |grep 'Jun 30th' | awk '{print $9}' | xargs mv -t /destinationFolder I'm trying to move files from certain date or pattern or createuser. It doesn't work properly without the -t option. ...
0
votes
1answer
39 views

Why do these commands produce different outputs?

I am trying to get the linux timestamp from a row of text. I can use the cut command to grab the string > echo '"tester_row_____",0,"2016-07-04T01:42:28Z","2016-07-04T02:00:58Z"' | cut -c 22-41 ...
3
votes
0answers
60 views

two piped commands, each needs to read password from stdin

Is there a way to sensibly do this: scp user@host:/path/to/file /dev/tty | openssl [options] | less without creating a file, and without having to supply either password directly in arguments? The ...
2
votes
1answer
31 views

Print stderr only if nothing gets written to stdout, otherwise print just stdout discarding stderr

There's a command that always prints stuff to stderr. Such information is never useful except when it doesn't write anything to stdout. So, is there a simple shell way, tool or command to help ...
0
votes
2answers
56 views

How to grep stderr? [duplicate]

How do I grep this command that includes a wildcard? How do I grep stderr? The grep does not seem to do anything: $ less /Users/raine/.nvm/versions/node/v5.5.0/lib/node_modules/* | grep "Not a file"...
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 ...
1
vote
0answers
57 views

How to send sudo password over pipe? [duplicate]

I need to replace existing sshd config on the remote PC and restart sshd, so I try to use this: cat /sshd_cfg | ssh user@192.168.0.47 "cat > /etc/ssh/sshd_config && service sshd restart" ...
4
votes
3answers
182 views

Why does `ps -e | less` show 'less' among processes? [duplicate]

I run ps -ejH | less. The output includes ps and less as well. What is the reason? I thought it would work as follows: First, ps will run and it will list all processes existing at that moment. ...
2
votes
2answers
69 views

Pass input file through pipe as argument?

I have two issues. I am trying to pass files through a pipe as an argument, and I am trying to use that file as a variable inside the sh function. Here is my command: find . -name 'segment*' | ...
0
votes
1answer
40 views

What's the proper way to read stdin inside parenthesis assignment of 2nd pipe

1st style, group 2 pipe to assign, this works: $ myresult1=$(curl -L 'https://archive.org/wayback/available?url=stackoverflow.com' 2>/dev/null | jq '.archived_snapshots.closest.url'); echo "$...
3
votes
1answer
67 views

set environment variables from stdout

How can you do the equivalent of piping stdout to 'export'? For background, I have a non-shell script that generates environment variables like so: DATABASE_URL='someurl' MAIL_KEY='key' REDIS_URL='...
1
vote
0answers
22 views

strace for troubleshooting inter process communication

I have output captured by following command: strace -f -e trace=process,socketpair,open,close,dup,dup2,read,write -o rsync.log rsync -avcz --progress src/ dst/ it is a bit long so I've uploaded it ...
0
votes
1answer
21 views

SQLite command line: How do you pipe output to a UNIX utility?

The SQLite documentation for its command line client indicates that its possible to filter output of SQLite queries through UNIX utilities: The default output mode is "list". [...] List mode ...
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 ...
0
votes
1answer
33 views

Error while replacing date in a file using tr command

I want to replace date in a file with my date. For this, I am giving below command - tr '2016-05-25' '2016-06-17' < APCSE060.20160525 > TESTFILE alternatively cat APCSE060.20160525 | tr '...
1
vote
1answer
48 views

netcat doesn't print response

I'm trying to send commands to a tcp port using netcat and pipe response when I run netcat and type my command it prints response correctly but when I pass command from a pipe it sends the command ...
17
votes
1answer
789 views

How to terminate a TCP connection established by bash itself?

I have used exec 3<>/dev/tcp/192.168.0.101/6435 to establish a TCP connection with 192.168.0.101:6435. And I have received as well as sent a few messages with the pipe command. Now, I want to ...
1
vote
0answers
25 views

Use a result twice in a pipeline [duplicate]

I have two programs progA and progB ./progA outputs a list like this : a1 a2 a3 a4 and ./progB take the result of progA as an argument and also outputs a list : b1 b2 b3 b4 I can pipe them like ...
4
votes
2answers
40 views

How would I get my terminal to regurgitate the previous output text from past commands? Is this even possible?

I just ran a job that takes several hours, and I forgot to pipe that text into a text file. pseudocode: echo [previous text output] > OutputHistory.txt Additionally, I can't just "copy and ...
5
votes
2answers
55 views

Can you scp, sftp, or rsync, a pipe?

I want to tar and send a ~700GiB directory to a remote drive I don't control. I don't have the HDD space locally to create the tarball and then copy that over. The remote is also protected by rssh - ...
1
vote
1answer
40 views

Pipe blocks with the following sequence of commands [duplicate]

I have a script that reads a file that contains urls and then prints out the ip addresses. However, I am unable to find resources as to why the pipe blocks when I add the command cut -d" " -f4 at ...
1
vote
1answer
31 views

Is it possible to pipe into dirsplit?

I'm trying to figure out the "Linux way" of accomplishing the following task. I have a directory with a bunch of sub-directories, each of which contain multiple files of various filetypes. I can ...
0
votes
0answers
40 views

What does the “pipe” command do in mailx?

When using the mailx command line utility, there is a command called pipe listed in the man page (although not visible when using the help command). What does this command do? I want to be able to ...
0
votes
0answers
45 views

How do I connect to Hyper-V VM's serial port from Linux?

I run Linux as a virtual machine on MS Hyper-V hypervisor from Windows Server (2008 R2 and 2012 R2, 2016 would be nice as well) and I want to read output from the VM's serial port (one-way ...
1
vote
0answers
33 views

When was pipelining introduced?

I understand early versions of Unix were licenced from AT&T to Universities and ran on PDP computers. I read in Tanenbaum's book (operating systems) that the first versions of Unix were only a ...
8
votes
1answer
93 views

Why doesn't file redirection to and from a named pipe work, but piping to cat does?

This is a simple echo server in Unix, using nc: mkfifo fifo cat fifo | nc -k -l 4458 -v | cat >fifo (based on this) As I can see it, the data flow works as follows: fifo (my named pipe) | | (...
4
votes
3answers
501 views

How do pipes and infinite streams work?

I usually use command1 | command2 | command3 a lot in Linux but most of them are dealing with definite content. When I tried this with an infinite stream cat | sed '' | sed '' which hopefully ...
0
votes
1answer
28 views

how to color specific strings in standard output and standard error [duplicate]

How do you color specific strings in standard output and standard error? For example: gpg --verify Outputs either a good signature or a bad signature string. How can I color the good one, green; ...
1
vote
1answer
44 views

Persistent process substitutions? [duplicate]

Is there a way to take a process substitution like <(grep foo some/file), and save it to a "file-like entity" on disk (reminiscent of a fifo), so that, every time this thing was opened for reading ...
0
votes
1answer
44 views

globbing and wildcards

Are wildcards ever supposed to be expanded for a program that is not the first in the pipeline? Every example uses wildcard for the first program in the pipelilne. For example, the following does ...
3
votes
2answers
39 views

Mark descriptor as terminal for the -t test

One can test if a descriptor is connected to terminal with -t test. if [ ! -t 0 ]; then echo "Stdin is not from terminal" fi Having a descriptor X, pointing to a file or to a process (with >(...
1
vote
1answer
53 views

Filter out duplicate lines of tail -f [duplicate]

I often need to tail -f apache access logs for websites to troubleshoot issues- one thing that makes it annoying is that anyone loading a page once may cause 12+ lines to get written to the log, and ...
20
votes
4answers
1k views

How to invoke vim editor and pipe output to bash

Sometimes I need to write text and then pipe that text into another command. My usual workflow goes something like this: vim # I edit and save my file as file.txt cat file.txt | pandoc -o file.pdf # ...
1
vote
0answers
7 views

Track amount of data application and a device file are exchanging

Is it possible to track how much data is going into a device file and an application as a third person? Background A web server is communicating with a device /dev/ttyACM0. The server offers a HTTP ...
2
votes
2answers
145 views

How do I double each line of piped output? [duplicate]

How do I double each line of input piped in? Example: echo "foobar" | MYSTERY_COMMAND foobar foobar
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. ...