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
3
votes
1answer
47 views

grep -q with openssl not working

If I execute openssl x509 -in ./somecert -text | grep SCTs I get the expected output. If I use grep -q openssl x509 -in ./somecert -text | grep -q SCTs I get unable to write certificate ...
57
votes
3answers
130k views

Bash: How to read one line at a time from output of a command?

I am trying to read the output of a command in bash using a while loop. while read -r line do echo "$line" done <<< $(find . -type f) The output I got ranveer@ranveer:~/tmp$ bash test....
21
votes
3answers
18k views

Direct output to pipe and stdout

I was wondering if there is a way to pipe the output of a command and direct it to the stdout. So for example, fortune prints a fortune cookie and also copies it to the clipboard: $ fortune | tee &...
50
votes
3answers
87k views

Piping commands after a piped xargs

HP-UX ***** B.11.23 U ia64 **** unlimited-user license find . -type d -name *log* | xargs ls -la gives me the directory names (the ones which contain log in the directory name) followed by all files ...
65
votes
7answers
23k views

Program that passes STDIN to STDOUT with color codes stripped?

I have a command that produces output in color, and I would like to pipe it into a file with the color codes stripped out. Is there a command that works like cat except that it strips color codes? I ...
0
votes
2answers
19 views

how to correctly redirect stdouts to pass file without comments to pacman input

I have a simple file with the following content: # programming python python-pip perl # web firefox firefox-i18n-es-es The file name for this example will be file. I usually use these files that ...
2
votes
1answer
1k 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 ...
1
vote
1answer
31 views

Use piped content in a python script passed as heredoc

I am aware that here-doc goes to stdin. I saw that here-doc takes precedence in going to stdin before what's coming from the pipe (see below). But maybe there's a trick to make it work? All in all I ...
1
vote
1answer
38 views

convert each line in a file into an input file

I am trying to convert/use each line from a file as an input file. For example file.txt contains the following lines: cat dog lion tiger rabbit Now, using the following command: cat file.txt | ...
1
vote
0answers
10 views

Pipe from xwd to ImageMagick's convert produces cropped image

I'm trying to take a screenshot of a remote host (using xwd) and convert it to png (using convert). I need it to be an unattended oneliner, so this is what I'm doing: sshpass -p THE_PASSWORD ssh user@...
0
votes
0answers
18 views

Local variables and pipes in Bash [duplicate]

I've jus wrote simple Bash program: #!/bin/bash function logMessage() { } var1=initial { true; var1=$?; } { false; var1=$?; } | logMessage echo var1 is: $var1 I expect var1 to be 1 (false) but ...
0
votes
2answers
33 views

Use input pipe and manage keyboard

I try to run a PHP script which read a flow by incoming pipe, and I want to manage the keyboard too : cat /etc/passwd|./readSlow.php The script will read each character from pipe and display it slowly ...
0
votes
1answer
32 views

How to manipulate the cal command question

I'm stuck on a question on my homework and can't figure the right options and pipes to use of cal or ncal. The question is the following: Write a command line to find the number of Monday(s) that fall(...
1
vote
2answers
74 views

What are the commands to solve the following

OBJECTIVE I have a file called graph that contains the textual description of a graph by listing all existing links between nodes. Each line contains one link, expressed like this : number1->...
1
vote
1answer
75 views

bash redirection again: question hard time understanding 2 similar commands

I would appreciate somebody explaining please why the following does work: # < /dev/urandom tr -dc 'a-zA-Z' | head -c 12 There is no '|' before tr , but the following doesn't: # < /dev/...
29
votes
3answers
22k views

Follow a pipe using less?

Can less follow (by pressing F) a piped input (similarly to a file)? For a file that is being written to, the command less <file> will follow the file when pressing F. But if I have a command ...
8
votes
4answers
5k views

Is there any way to exit “less” follow mode without stopping other processes in pipe?

Often times I find myself in need to have the output in a buffer with all the features (scrolling, searching, shortcuts, ...) and I have grown accustomed to less. However, most of the commands I use ...
0
votes
1answer
17 views

Auto-close tmux pane when its stdin is closed

I made a program where I use the classic pipe-fork-exec to have a pipe connected to a process running tmux split-window -dI, so when I write to that pipe, the newly created pane print what's written. ...
3
votes
1answer
2k 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 redirect ...
8
votes
2answers
13k views

Why does this script with a FIFO pipe not terminate?

This script: #!/bin/bash tmppipe=/tmp/temppipe mkfifo $tmppipe echo "test" > $tmppipe cat $tmppipe exit does not terminate. I assume that the cat command is waiting for an EOF from the ...
7
votes
1answer
2k views

If no input is given to xargs, don't let xargs run the utility

I have this command: docker volume ls -qf dangling=true | xargs docker volume rm I get this: "docker volume rm" requires at least 1 argument. See 'docker volume rm --help'. Usage: docker volume ...
37
votes
5answers
18k views

Measure pipe throughput in the shell

There is a shell command that allows you to measure how fast the data goes through it, so you can measure the speed of output of commands in a pipe. So instead of: $ somecommand | anothercommand you ...
1
vote
1answer
1k views

How can I get feh to set wallpaper to each monitor according to its size?

I have a directory filled with png files $ tree ~/wallpaper/ ~/wallpaper/ ├── foo--1366x768.png ├── foo--1920x1080.png ├── foo--2048x1080.png ├── foo--3440x1440.png └── foo--3840x2160.png 0 ...
0
votes
1answer
48 views

How to grep on files less than a size and limit to extension [duplicate]

I want to recursively grep on all files in subdirectories with extension csv but select only those files that are less than 4M in size. Is this correct way to do? find . -type f -size -4M | grep --...
-3
votes
1answer
51 views

I am learning how to use grep and came across this. How does it work? [closed]

What would grep '#' input.txt | tail -n give me? I am new to this and cannot figure out what happens using grep and tail together.
0
votes
1answer
14 views

Long-running pipeline of events [duplicate]

I can't get this working on macOS: unbuffer fswatch . | unbuffer xargs echo What am I doing wrong? fswatch is like inotifywait on other systems.
0
votes
1answer
49 views

How to pipeline sleep? sleep pipeline doesn't work

I wanted to simulate execution time of certain scripts for which I found sleep NUMBER does exactly what I want. In my scenario I needed something like sleep 5 | command | sleep 5 ... But it behaved ...
3
votes
1answer
2k views

How to redirect and use the framebuffer?

I need to work on the framebuffer to record what is being rendered. Now, I figure out how to convert the framebuffer in an image, I'm currently unable to obtain a constant stream of data from the fb ...
0
votes
1answer
18 views

How to uncompress a gzipped partition image and dd it directly to the destination partition without writing to current partition?

I've backed up a partition using sudo dd bs=8M if=/dev/sda2 | gzip > /someFolderOnSDB/sda2.img.gz. The image is stored on a separate disk sdb. When restoring it using gunzip -k /mnt/bkp/sda2.img.gz ...
235
votes
15answers
473k views

How do I trim leading and trailing whitespace from each line of some output?

I would like to remove all leading and trailing spaces and tabs from each line in an output. Is there a simple tool like trim I could pipe my output into? Example file: test space at back test ...
2
votes
3answers
56 views

Bash block redirection and piping

I'm learning bash redirection. I expect the following code to do the equivalent of ls | grep foo | grep bar. #!/bin/bash { { ...
1
vote
1answer
33 views

Redirecting to `stdin`: who outputs the contents afterwards?

Consider the following example in Bash shell $ echo 'test' | wc -c 5 Everything works as expected. Now let's change it to $ echo 'test' >&0 | wc -c test 0 Now, that 0 in the output makes ...
0
votes
1answer
26 views

rsync: read list of files from pipe

I can transfer file /tmp/file using rsync to remote server: rsync -R -av /tmp/file root@server:/ but how can I provide the list of files to be transfert from a pipe? I tried using the --files-from= ...
2
votes
1answer
5k views

set -eo pipefail differs on ksh and bash

I would like like to terminate a script on any failure including inside a pipe. In bash, you can set -eo pipefail, but this doesn't work in ksh. Example: # x set -eo pipefail false | true echo "done:...
9
votes
5answers
7k views

How to get `yum list` output to stay on one line when getting output via remote ssh command?

When I SSH to a machine with ssh machine and run yum list it outputs everything that's installed as expected, and importantly every item is on one line like so: xz-devel.i386 ...
0
votes
1answer
41 views

How can I pipe stdout to another process, whilst also capturing stdout in a local file?

With a command as follows: program_that_produces_stdout | program_that_captures_stdout I would like to capture the output of program_that_produces_stdout in a file locally too. Obviously ...
16
votes
6answers
3k views

Utility to buffer an unbounded amount of data in a pipeline?

Is there a utility that I can stick in a pipeline to decouple read and write speeds? $ producer | buf | consumer Basically, I want a utility buf that reads its input as fast as possible, storing it ...
0
votes
1answer
25 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 ...
1
vote
2answers
60 views

Pipe user input to another program

I know that running cat with no argument reflects the user input $ cat test test reflected reflected I want to pipe the reflected output to another program such as base64. The expected behavior is ...
0
votes
0answers
22 views

kill can't kill background process in script

For a reason sudo pkill $(jobs -p 1) can't kill the process but sudo pkill works outside the script #!/bin/bash pipe=/tmp/outpipe_vpn mkfifo $pipe ##random command to enter sudo password sudo echo ...
1
vote
1answer
28 views

Running Complex Command with SUDO

I need to run the following command with sudo (technically just the dd part of this command needs sudo): xz -d -c -v nvme0n1.dd.xz | xdelta3 -e -9 < (dd if=/dev/nvme0n1 bs=1GB) nvme0n1.dd.xdelta ...
19
votes
1answer
1k views

What happens when writing gigabytes of data to a pipe?

Let's say I have a makefile with a recipe called hour_long_recipe, which as its name suggests takes an hour to run. At random points throughout the recipe it asks yes/no questions. Let's say it asks ...
2
votes
1answer
42 views

What is difference between `command | cat > output.txt` and `command | > output.txt`

Why can't we direct these outputs into the file after route with Pipe? You can understand much better what i mean by the example. In my example, why can't I route output with only the routing operator(...
1
vote
2answers
40 views

How to pipe a number into bc elegantly?

Is there a more elegant way than using xargs -Ix for the following? echo "283" | xargs -Ix bc -l -e "scale=2; l( x )/l(10)"
0
votes
1answer
32 views

how we can pipe endless commands like yes?

As far as I know piping command A to command B will execute A and give it's output to B as input. While some commands are endless, like yes, and therefore execution time for these commands is until we ...
2
votes
1answer
33 views

Why is this systemd user service with piped output not showing in journald logs

I have the following service: [Unit] Description="Hoping to get rich" [Service] ExecStart='/home/me/Dev/hellogoogle.sh' Restart=on-failure RestartSec=5s [Install] WantedBy=default.target ...
0
votes
1answer
23 views

How to pipe text output to speech dispatcher?

I am not getting the command pipe to work for say and spd-say. Specifically, I want to pipe the output of fortune to spd-say, which seems more advanced than say. I tried the usual pipe construction ...
1
vote
2answers
74 views

Makefile: how to sed correctly to edit a variable

I'm trying to write a custom Makefile in which I collect all source files to compile against the main. First I collect their names: # other sources to compile against (without extensions, separated by ...
1
vote
1answer
46 views

Pipe output to command line editor for next command

I have been using sudo find / -iname '*foo*' 2>/dev/null | vim to get a list of directories/files containing foo, and then I inspect this list, edit it, and write a bunch of new commands inside of ...
-2
votes
2answers
46 views

Is there a command or program can add line number to display by pipe? [duplicate]

I always need to find some key words in thousands of feedback and locate it in which line. I used to redirect feedback to a file, and open file wiith vim, and execute vim command :set nu to do this. ...

1
2 3 4 5
32