Questions tagged [pipe]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Underlying failure after a SIGPIPE

I am getting an error code 141 when running a bash script on a CI server that I cannot reproduce locally. After some searching, it sounds that error 141 indicates a PIPEFAIL, and I have a set -o ...
0
votes
2answers
33 views

Filtering ping output through multiple pipes fails

Trying to capture only the packets return time from ping output, I issued $ ping 192.168.0.1 | grep -o '[^ =]* ms' and it worked, displaying each packet time when it arrived. Since I also wanted to ...
0
votes
0answers
11 views

Pipe email through translation program and save results to mailbox

My mail service uses exim to filter mail and I have some experience putting in various conditions in my .forward file. However, I have a more complex problem that I don't know how to solve. ...
0
votes
0answers
12 views

Streaming to FIFO-Q: how to copy into two streams, and operate on the new streams?

This question is about pipes, and I have created a small problem to illustrate my issue. Suppose I have a file: // foo.csv a,b,c d,e,f In script bar.sh, I do the following: A=`mktmp -u` B=`mktmp -...
0
votes
2answers
58 views

Can I cp to stdout/pipe?

Ok, it might sound weird but bear with me. I want to use cp to copy content of my block device, and I want to pipe it to gzip to compress it on the fly. Can I do this with cp? I know I can use dd, but ...
1
vote
1answer
65 views

Why is `BrokenPipeError` dependent on the size of the piped stream?

The following script raises BrokenPipeError: [Errno 32] Broken pipe, when piped to a command like head (unless the number of lines to head exceeds the number of lines printed by the Python script). ...
0
votes
2answers
25 views

How do I pipe the results of a “find” or “ls” to a file AFTER it has completed its stdout?

So for some reason when I do something like find $PWD -type f > listoffiles.txt To create a list of files in current directory and save it to a list, The file "listoffiles.txt" itself is somehow ...
0
votes
1answer
34 views

Named pipe buffer after process end

I am creating named pipes in Ubuntu 18 and 16 environments in C language using gcc as compiler (mkfifo() and open()). One of the things I noticed that the named pipes remain in the filesystem after ...
0
votes
0answers
18 views

modify binary output before returning to the prompt mode

I have a binary which prints the question and then waits for a user answer. I have no access to the source code of this binary, but I want to modify the screen output. Example: > ./commandx Day ...
0
votes
0answers
25 views

Show ports in hexadecimal for netstat or ss command

I am trying to format the output of netstat or ss command in bash terminal. I need to convert the port numbers to hexadecimal. Currently they are shown in decimal by default. Is there any option in ...
0
votes
1answer
57 views

Interacting programs stdin and stdout (create a robot program to play a game)

The setup: I have an executable file, that I "cannot edit", since I don't have the source code. When I execute the program it reveals a game, where it hands me some numbers via stdout, for me to ...
2
votes
1answer
112 views

problem understanding system(“/bin/sh”)

I'm having problems understanding why this program #include <stdio.h> #include <stdlib.h> int main() { int iRetval = 0; unsigned int uiNum; printf("Enter number: "); ...
0
votes
0answers
32 views

pipe script to bash and also use read

If I do this: $ { > sleep 1 > read -p "Press Enter to continue" > } I get the prompt after a second, as expected. Now, if I do this: $ echo 'sleep 1; read -p "Press Enter to continue";' | ...
0
votes
0answers
31 views

sudo from standard in on interactive command

I'm trying to run the command cat ./password | sudo -Skp '' yum install git and it goes through the motion and finally gets to the last line where it returns Is this ok [y/N]: Operation aborted. ...
0
votes
1answer
30 views

Best way to set a conditional output filter (head or output “as is”) [duplicate]

For testing purpose, I want to activate or not a filtering with the command head. For example, the command below could outputs a lot of lines #!/bin/bash produce_a_lot_of_lines I want to set on ...
0
votes
0answers
24 views

Mailgun script working and | tee not logging

I've got a bash script running from Windows task scheduler: Looks like this: C:\Windows\System32\bash.exe -c "sudo /root/borgbackup.sh 2>&1 | tee -a /tmp/borg.log | sudo /root/mailgun 2>&...
19
votes
2answers
2k views

Piping commands with very large output

I want to tar a directory and write the result to stdout, then pipe it to a compression program, like this: tar -cvf - /tmp/source-dir | lzip -o /media/my-usb/result.lz - I have been using pipe all ...
0
votes
0answers
54 views

pipe into if then in csh/tcsh

I would like to have a csh script to test a variable between two pipes. For example (the incoming resembles a json file but without the newlines and indentations): set debug = 1 cat test.inp | if ($...
24
votes
5answers
1k views

Redirecting a pipeline into the file from which it originated

One might think that echo foo >a cat a | rev >a would leave a containing oof; but instead it is left empty. Why? How would one otherwise apply rev to a?
1
vote
1answer
33 views

virt-install: send guest command from a host script

I can redirect virt-install input/output to console with the --console option: virt-install \ --name centos \ --ram 1024 \ --os-type linux \ --os-variant centos7.0 \ --graphics none \ --...
0
votes
0answers
36 views

Redirect output of <command> --help via ccat?

I can ls --help | ccat but I want ls --help print the same colored output as ls --help | ccat. In short, I want all commands to be filtered through ccat. How may I do this in the zsh shell?
0
votes
0answers
39 views

Postfix Pipe command

I am trying to run a script when postfix recieves an email and have found an example that I mostly understand. my_shell_script unix - n n - - pipe flags=F user=MY_USERNAME argv=/path/to/my/shell/...
0
votes
3answers
81 views

Why doesn't this use of the pipe operator work? [duplicate]

I normally use pidof to get the pid of a process, and KILL -SIGTERM <pid> to terminate it. The pipe should give the output of one command as an input to another. So why doesn't the following ...
3
votes
2answers
47 views

Printing to terminal while piping

% ping -c 3 stackexchange.com | rev >/tmp/rping saves the result of pinging and reversing. I would like to do this while at the same time printing the unreversed output of ping to the terminal. ...
0
votes
1answer
62 views

How to run lxc exec for commands with pipe?

for example, I have this command: lxc launch ubuntu:18.04 memsql1 lxc exec memsql1 -- wget -O - 'https://release.memsql.com/release-aug2018.gpg' 2>/dev/null | sudo apt-key add - && apt-...
3
votes
1answer
53 views

How to can I cause an exit, from a script that receives data through a pipe, from another program?

I have Bash script that is used to process data, which is sent through a pipe from another process. I'm trying to add a functionality that causes and exits after a certain condition is met, whose ...
1
vote
1answer
15 views

mysqldump into file with any error firing off a cURL request with error information

I'm attempting to setup a backup that I want to execute from the command line where, in the case of an error, it curls the error to an API endpoint. Something like: mysqldump -u whatever -pwhatever ...
0
votes
1answer
32 views

How to prepend value to the cat command output without modifying a file?

At work, there is a custom script that I must use to apply a SQL script to a mysql database server and have no liberty to modify. The command line options of the custom script is very limited. For ...
0
votes
1answer
68 views

Is there a way to overwrite pipe on linux bash?

I was wondering if there is a way to replace the default behavior of the | command in bash with a custom command. I would like overwrite the pipe command. This is a strictly technical and ...
1
vote
1answer
87 views

How can a command within a pipeline abort the pipeline?

Given the pipeline a | b | c how might I alter b so that it aborts the pipeline if b generates an error or matches a particular pattern in the input stream?
0
votes
1answer
83 views

cat | dd pipe causes partial reads without iflag=fullblock, why truncated to 128KiB?

Consider this sample 1MiB file: $ dd if=/dev/zero of=input.img bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00100595 s, 1.0 GB/s If I try to cat it and pipe ...
0
votes
1answer
47 views

read pipe input from keyboard

This is very basic, sorry if this is a duplicate, but search results give me something opposite. I want to paste lines as an input to a pipe. How can I do it? For example I want to use this answer ...
1
vote
1answer
23 views

Piping md5sum output to grep, but grep is highlighting matches instead of removing non-matches

I have downloaded multiple files from a repo with many more files. The md5sum information for each file is stored within a single file called MD5SUMS. To check file integrity I did md5sum -c MD5SUMS ...
1
vote
2answers
130 views

Send mail on change of line in log file, tail -f piping to mail doesn't work

I have a nginx access.log There is very infrequent traffic, so I want to get a mail on each access. I've tried tail -f access.log | cat That works. So piping with tail seems ok. With following ...
-1
votes
1answer
53 views

input from multiple pipes

How pass arguments from multiple pipes? command1 | command2 outputOfcommand1 | command3 outputOfcommand1 outputOfcommand2 What I trying to do more specifically is to list some directory inside ...
1
vote
1answer
63 views

How to process a logfile from tail -f into awk into jq?

My Use-Case is as following: I have a Apache Logfile where I am logging only json-data from PHP. Because of how Apache is printing the Logs I have to trim the start and the end of each line with awk. ...
0
votes
3answers
43 views

How do I pass piped input to second command in an alias?

I've defined an alias like: alias xyz='command1; command2' I want to pipe output of another command pqr to command2 like: pqr | xyz -f - Is it possible? How can I achieve that?
0
votes
2answers
112 views

How to count the number of lines in the middle of a pipe

I want to count the number of lines in a pipe and then continue the pipe depending on the outcome. I tried x=$(printf 'faa\nbor\nbaz\n' \ | tee /dev/stderr | wc -l) 2>&1 \ | if [[ $x -ge ...
0
votes
0answers
22 views

Set named pipe as pattern

Some introduction: I have a program, which works with named pipe and gives as output a directory with a certain name. The directory will be filling by several files with certain patterns (e.g., *R1* ...
1
vote
1answer
74 views

How to pipe git log to curl command

My goal is to perform a curl with the output of a command as curl payload, separately they work, but i have not been able to merge both things into one. This is my first command, it prints the ...
0
votes
1answer
52 views

piping ls to other programs vs loop globbing [duplicate]

I am reading about the pitfalls of parsing ls and the examples given are about looping ls with for/while. The article title says 'parsing ls' - does that mean piping the output of ls to awk and other ...
1
vote
1answer
48 views

less scroll to the end without blocking

I'd like to pipe a process to less, and then issue a command to the scroll the end of the current piped text. That is, shift+G blocks if the command hasn't yet closed its stdout, so for a long-running ...
0
votes
1answer
62 views

How to capture stdout and sterr AND proper piped exit status in Shell command?

I want to be able to do the following: command 2>&1 | shell_script.sh "subject line" Where the stdout and sterr of running command will be piped to shell_script.sh for sending as the body of ...
2
votes
0answers
26 views

Pipe output to a command while still writing to stdout [duplicate]

I have a command that writes to stdout, let's say it's ls. I want to pipe its output to a program foo, while still writing that output to stdout. I looked into tee, but I couldn't figure out how to ...
-4
votes
1answer
220 views

Why am I getting this [Broken pipe] error?

I'm on Ubuntu 18.04. I'm trying to do a buffer overflow attack. Here's the C program I wrote and am trying to attack: // test.c #include <stdio.h> void f(); int main(int argc, char *argv[]) {...
0
votes
2answers
62 views

Piping Output of Shuf Command [duplicate]

Fairly new to Linux. I have a nixie clock that runs off of a Raspberry Pi. I would like to send a random sequence of six digits to it every so often to help prolong the life of the Nixie tubes. ...
0
votes
0answers
23 views

scp `ls -liart | tail -n5 | grep 0001` wuxi-jump-128:/tmp fails: No such file or directory

I hope to make scp work with pipe, like firstlove@chenli ~/Downloads $ ls -liart | tail -n5 | grep 0001 51384329 -rw-r--r-- 1 firstlove firstlove 1440 Oct 31 ...
1
vote
0answers
34 views

Can I open an editor as part of a piping command to edit the piped string? [duplicate]

I would like to do this: git --git-dir=../navcl/.git format-patch -k -1 --stdout 607780ee9 \ | nano \ | git am -3 -k The issue is, in my other git dir, a file path is different, so I need to ...
0
votes
1answer
56 views

bash script combining commands enable flags?

I made a basic bash script piping fortune and cowsay to make a wise cow, and titled it appropriately as wisecow Is there a way I can enable the flags associated with cowsay so that I can input ...
0
votes
2answers
116 views

How to print the output of `read -p` to stdout and another file

I was doing echo -n " - This directory is not empty, purge? (Y/N): " | tee -a $mylogs read choice echo "$choice" | tee -a $mylogs but I wanted to try to condense it to: read -p " - This ...

1 2 3 4 5 29