Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pipe]

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 "|".

0
votes
0answers
15 views

How to navigate back in MORE pager in Ubuntu? [duplicate]

I used the more pager to look a calendar, i was able to move forward using ENTER key or a space bar but when i tried to move backward, i was unable to do so , i saw somewhere that b key can be used to ...
0
votes
1answer
10 views

using sudo with piped command on Ubuntu server

If I need to use the following backup command on an Ubuntu server with sudo, how do I do so? Do I need sudo at two places? tar cf - directory | 7za a -si directory.tar.7z
1
vote
0answers
27 views

Killing a process when some other process is finished

Given a | b, i'd like to kill b when a is finished. b is an interactive process, which doesn't terminates when a is finished (fzf in my case), and the whole a | b is executed in a $() subshell. So ...
0
votes
0answers
15 views

failed using scanf to read from pipe [migrated]

Working on IPC I was asked to write a C program that works as pipe between other two C executables: The first executable named 'sln1.out' receive six arguments and print three numbers. The second ...
0
votes
0answers
26 views

while read loop seems to terminate after the first line, when using two pipes?

#!/usr/bin/env bash set -euo pipefail while read -r line do echo "line via echo:" echo "$line" echo "line via sed:" sed 's/w/f/g' | sed 's/f/zzzzz/g' <<< "$line" done < /dev/...
0
votes
0answers
15 views

Buffering issue when looking at netcat output

I have problem I am trying to understand: I am sending some UDP data to local host. It is a simple UDP packet with a counter. It counts up to 16 (0xF) and stops. When I grep the received data on the ...
0
votes
2answers
43 views

STDOUT + STDERR output … is there any difference between considering the output to be an empty string vs NULL

I'm writing some application code that is used to execute Linux shell commands, and it then logs the command details into an SQL database. This includes the output of STDOUT + STDERR (separately). ...
0
votes
3answers
32 views

Exit pipeline early on command failure

I looked at Exiting a pipeline if a former command fails but I'm looking for a more general solution to this problem: chlist -q -v -m -r $sourcelist | \ grep '^USER:' | \ chlist -q -v -f - $superlist ...
1
vote
1answer
34 views

Bit banging with dd?

I need to change one byte at a well-known position of a binary file to a specific value, and am looking for a way to achieve that using command line tools. Constraints: I need to change one single ...
0
votes
2answers
71 views

Why doesn't grep remove lines of terminal output from find command by default? [duplicate]

I am constantly frustrated by this simple command: find / | fgrep somestuff.ext When I don't use sudo, I get line after line of permission denied - which is fair enough, but why isn't this output ...
0
votes
2answers
30 views

How do I diff the output of these two commands? [duplicate]

I have an alias which I use to strip out comments that are piped to it: alias decomment='egrep -v "(^#.*|^$)"' I'm currently having some difficulty with a squid proxy setup, so I want to compare ...
1
vote
1answer
18 views

A command wants file paths. How can I give it stdin for the “infile” and stdout for the “outfile”?

Consider a command like foo -in /path/to/infile -out /path/to/outfile, that you'd like to pass strings to rather than using temp files. It may be called a lot causing much disk access, or is related ...
-3
votes
2answers
89 views

Calling sh with script on stdin and passing command line arguments

This works of course. I can run ./test1.sh cats and the argument cats is passed correctly to ls. $ cat test1.sh #!/bin/sh ls -l $1 Can you tell me how do I make this second example — the same ...
0
votes
0answers
20 views

Is there a good way to remove text formatting by piping through a program? [duplicate]

I have a program (expressvpn) which is outputting to terminal with some sort of color formatted text. If I execute expressvpn status i get back Connected to USA - Seattle - If your VPN ...
0
votes
2answers
62 views

sed not working correctly when piped

For some reason, I will not have live output when piping the command output of e.g. SSH to sed: ssh someuser@somehost 2>&1 | sed -e "s/\[32//g" | tee logging I suspected that the output dit ...
0
votes
0answers
43 views

How to use sox to convert mp3 file from stdin?

I have a situation where I get a mp3 audio output in the stdout, and I'd like to save it directly in a wav file. Example: I could do that: gtts-cli "Hello World" -o out.mp3 && sox out.mp3 ...
0
votes
2answers
38 views

wget and scp as a pipeline

Can we use wget and scp as a pipeline. I want to wget a file from a server and copy to another server. I used below command but it is not working. wget "$Select_Release_Version_ARTIFACT_URL" | sudo ...
1
vote
1answer
16 views

Piping output of zypper ps -sss into systemctl restart

I do not want to restart the server after a zypper up. Instead I want to restart all services using deleted files as shown by zypper ps -sss. I thought I could do something like zypper ps -sss | tr '\...
1
vote
2answers
35 views

Trying to perform two operations on a single huge source file to gain performance

I am performing two operations in a single Linux command. The operations are: Sending data from source file into a new target file. Counting the number of records in the source file. For example: ...
0
votes
0answers
59 views

tail: error writing 'standard output': Broken pipe

I tried to use some scripts which use tail commands on Debian stretch but I got tail: error writing 'standard output': Broken pipe. Does Debian handle tail and pipe syntax differently? Thank you in ...
2
votes
1answer
39 views

How can I write directly to a Solaris FIFO pipe over ssh?

I have a Solaris server running a process that has its input and output redirected into FIFO pipes (fifo_in, fifo_out). How can I connect to these two pipes over ssh? I would like to be able to ...
0
votes
0answers
52 views

Tail with case statement is not working properly [duplicate]

I want to monitor the logs continuously and echo the output if keyword appears then continues the monitoring!! My question is how to perform the below operation tail the logs if keyword[down] ...
1
vote
1answer
46 views

Number of home directories in children of /

I have to count the number of children directories of / that contain one or more home directories. For instance, if john, emily and rick have their home directories in /home/john , /home/emily and /...
1
vote
1answer
59 views

Using variable instead of a cat output [closed]

In a shell script how can I get the same output from a variable for piping like a command does (for example: cat data.dat | awk ...)? list=`cat data.dat` then update list with running it through awk....
2
votes
0answers
31 views

Knowing when bash is done running a command through a FIFO pipe

I'm trying to link a web-based terminal with bash. My current attempt to do so is spawning a shell pointing a FIFO pipe to its input, like this: Terminal 1 $ mkfifo pipe $ bash <> pipe file1 ...
0
votes
0answers
20 views

How can I pipe stdin inputs to command which expects multiple stdin inputs?

yes mypassword | while true; do sudo -S sleep 3; sudo -k; done can supply multiple identical stdin inputs mypassword to the while loop. When both sudo -S and the command it executes need different ...
0
votes
1answer
21 views

Pipeline running in parallel through creating multiple subshells

I read from this answer about the distinguish between | and ; https://unix.stackexchange.com/a/159492/318084; Consider two commands A and B. When you write A | B A and B are executed in ...
0
votes
0answers
10 views

How pipe/redirect influences the execution of the script which output is to be piped/redirected? [duplicate]

I stumbled on the example of something I wasn't aware to be possible, that the mere fact of putting | or > after the script, can influence of how it will run. Details of how I realized it can be ...
1
vote
1answer
26 views

How to pipe to less unbuffered?

I'm trying to display progress, and make it usable under less: while true; do echo -n .; sleep 1; done | less Is there a way to make it work?
1
vote
0answers
98 views

sed: couldn't write n items to stdout: Broken pipe. What are these errors? [closed]

I have a bash script which executes a php code and sleeps for 60 seconds and repeat same thing again The php code does some json parsing and run bash scripts with shell_exec I know bash inside ...
0
votes
1answer
39 views

Pipe to fifo from script

I want to send commands from a script to twinkle (the VOIP software). I thought I could do this with a named pipe so I have created one mkfifo phonecmd If I start twinkle and pipe tail from the ...
0
votes
1answer
47 views

read from stdin works differently in bash and zsh [duplicate]

I'm trying to pipe a command's output to the read builtin of my shell and I get a different behaviour for zsh and bash: $ bash -c 'echo hello | read test; echo $test' $ zsh -c 'echo hello | read ...
5
votes
1answer
90 views

Why does the rpm command have a '--pipe' option?

From rpm's man page: --pipe CMD Pipes the output of rpm to the command CMD. Why was this added? Why would you use it instead piping via the shell itself?
0
votes
1answer
19 views

concatenating 2 commands with tar (wc -l + echo ok || echo fail)

I want to do 2 things with a tar.gz file: Check for failure If successful - check number of files extracted I found this for the 1st option. I now run my command like this: tar -xvzf bad_file.tar.gz ...
-1
votes
2answers
79 views

Tee does not write to file when combined to pipe

I'm trying to run a C code with matlab, developed by others. In c, it's written to stdout, then in matlab a pipe is created and read: unix('rm -f /tmp/matdata.in;mkfifo /tmp/matdata.in'); unix(['./',...
-1
votes
2answers
41 views

How to use sed on all matching files?

I am trying to run sed on the output from find | grep \.ext$ However, sed requires input file and output file. How can I save the output line to a variable, or pass it to sed?
-1
votes
2answers
34 views

gunzip on all present files safety regarding memory

I want to look for the presence of a string on all gziped files on server. I am afraid if I run something like gunzip -c *.gz | grep "string to be searched" server get overloaded with cache for ...
18
votes
1answer
3k views

Why does piping `tar` into `dd` not stop until the disk is full?

I have a tar archive of a single disk image. The image inside this tar file is about 4GB in size. I pipe the output of tar xf into dd to write the disk image to an SD card. The diskdump never stops ...
1
vote
1answer
43 views

Pipe Output of Executable to Existing Netcat Connection

I open a terminal window and connect to shell using netcat: Terminal Window 1: nc hostname port Then, I navigate to a directory and open a file,... etc (I would need to be able to do this myself, ...
5
votes
3answers
667 views

Opening most recently modified file in vim

The following commands work $ ls -1t | head -1 git_sync_log20180924_00.txt $ vi git_sync_log20180924_00.txt But this does not $ ls -1t | head -1 | vi Vim: Warning: Input is not from a terminal Vim:...
0
votes
1answer
52 views

How to read only the last line of a live input stream in a while read loop

I have a very simple bash script that synchronizes data to a USB key as soon as new files appear. It is poorly written but it works, however I want to minimize CPU time so I used sleep but since I use ...
4
votes
3answers
95 views

In what format does piped output get sent and received from one command/program to another? [duplicate]

When a command is piped to another command in what way or in what format does the piped output exist/get sent? Is it a temporary file? Is it a string? And how does the command that receives the piped ...
1
vote
2answers
87 views

How to check left command's exit status in pipe “left | right” in dash when left command produces large output

It seems that the variable "PIPESTATUS" is unavailable in dash. Simple separate execution is not working because the left command produces very large output. I used a fifo to do this task: #!/bin/...
1
vote
3answers
106 views

How does a program know what to read in a pipeline? [duplicate]

How does the unix command line program know what file to read? For example: cat someFile | foo How does the program foo know which file to read, and which process is responsible for opening and ...
1
vote
2answers
79 views

Print netcat input on terminal

I'm trying to write a script where I cat the content of a file and pipe it into nc: $cat somefile.txt | nc server port The file content is sent to the server as expected but on the terminal I only ...
4
votes
0answers
40 views

Random errors thrown by Bash shell: cannot open named pipe

I have found that keeping a detailed log of every command I run, from which path I ran it from and which user I sudo'd from, is extremely valuable as the years go by and I'm trying to remember what I ...
3
votes
1answer
73 views

Is there a way to specify a section of a pipeline be completely “pass through”?

I have a script in which data is processed by streaming it through a fairly large pipeline. Several sections of the pipeline are actually "switchboard" functions that do different things based on some ...
0
votes
2answers
77 views

Have xargs pass a flag from stdin instead of command parameter

Given an application, myApplication, that streams lines to stdout $ myApplication flag1 flag2 flag3 How do I use xargs to pass those values as flags to a command instead of passing them as ...
1
vote
2answers
280 views

Streaming Data to REST Service Using Unix Pipes

Based on an answer to another question I am using curl to stream the stdout of one process as the entity of a POST request: myDataGeneratingApp \ | curl -H "Content-Type: application/json" -H "...
1
vote
1answer
60 views

How to ignore interrupts with piped commands

In the following chain of piped commands, when an interrupt is sent with Ctrl-C, ping is able to print its summary statistics before exiting, as long as tee has the -i (ignore interrupts) flag: ping -...