Questions tagged [pipe]

A pipe connects the output of one program to the input of another program. This is especially used to implement the shell | operator.

A pipe connects the output of one program to the input of another program. It is one of the fundamental interprocess communication mechanisms on Linux.

In the , the | operator creates a pipe connecting the process on the left to the process on the right. For example

mycommand | less

sends the output of mycommand to the command less, which displays its input (i.e. the output of mycommand) in an interface allowing navigation and searching.

205 questions
346
votes
9 answers

What is the difference between "Redirection" and "Pipe"?

This question may sound a bit stupid, but I can not really see the difference between redirection and pipes. Redirection is used to redirect the stdout/stdin/stderr, e.g. ls > log.txt. Pipes are used to give the output of a command as input to…
John Threepwood
  • 3,777
  • 5
  • 18
  • 12
173
votes
5 answers

How do I pipe terminal standard output (stdout) to the clipboard?

Say I want to list the contents of a folder and directly paste them into a chat window for a friend to see. I realize I could do ls > filename.txt to create a file (filename.txt) with those contents; I'd then have to open or print the file and…
Insperatus
  • 5,093
66
votes
4 answers

Why use a named pipe instead of a file?

I recently read about named pipes, and I couldn't understand why they exist. I've read somewhere that using a named pipe is less time-consuming than using a file. Why is this so? The named pipes also have to be stored in memory (and maybe swapped,…
bsky
  • 1,419
41
votes
5 answers

Kill Java processes

I'm working on a computationally heavy code that - for now - crashes a lot, but I'm still working on it :) When it crashes, I can't close the GUI window; I have to open a shell and kill -9 the process. It is a Java process and it is easy to…
nkint
  • 2,065
34
votes
4 answers

How can I direct a pipe input to ls command?

When I type something like: find . -name *foo* | ls -lah it returns the same result as a plain ls command, as though it had no input. However: ls -lah $( find . -name *foo* ) works well, but only when the find command has results. Is it possible…
Lasall
  • 3,733
33
votes
8 answers

Why doesn't the command "ls | file" work?

I've been studying about the command line and learned that | (pipeline) is meant to redirect the output from a command to the input of another one. So why does the command ls | file doesn't work? file input is one of more filenames, like file…
IanC
  • 951
29
votes
1 answer

Uncompress and pipe the output to script

I have a script that takes an input with a -i flag. The input file I have is compressed (.gz). What I want to do (not sure it's possible), because the file is huge, do some thing like this: gunzip -c myfile.gz | myScript.pl -i STDIN -o myoutfile.txt…
crysis405
  • 793
23
votes
1 answer

Is it possible to pipe from stdin to gzip?

If I run the command s3cmd get s3://bucket/file.gz - I get binary output on the screen. If I try to pipe this to gzip with s3cmd get s3://bucket/file.gz - | zcat I get gzip: stdin: not in gzip format. How can I get zcat to pick it's input from…
KalenGi
  • 415
  • 2
  • 8
  • 10
21
votes
7 answers

How do I execute FTP commands on one line?

This is what I'm doing when I log into a FTP: ftp user:password@server ftp: user:password@server: Unknown host ftp> echo HELLO WORLD! ftp> quit I'd like to do a one-line FTP command... ftp user:password@server -command "echo HELLO WORLD" or "echo…
WernerCD
  • 652
19
votes
5 answers

Appending a line to a file in the cat command?

I can do cat file.txt to get the contents of a file but I also want to tack on a final line of my own choosing. I tried piping (cat file.txt ; echo "My final line") | but only the final line is getting passed through the pipe. How can I join the cat…
19
votes
2 answers

Tee doesn't get whole output from the pipe

I have a script executing commands like: export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH;./some_app -i $INDEX | tee $LOG echo "Number of errors: $(grep "ERROR" $LOG | wc -l)" The problem is probably in the pipe to tee. It does not seem to get the whole…
19
votes
4 answers

How to delete all files that are returned by locate

At the moment his is what I do: Step 1: locate fooBar /home/abc/fooBar /home/abc/Music/fooBar Step 2: Manually perform a removal, by copy-pasting each line. rm /home/abc/fooBar rm /home/abc/Music/fooBar How do I do this in one step? Something…
theTuxRacer
  • 16,533
18
votes
3 answers

How do I pipe a newline separated list as arguments to another command?

So I have a list of usernames such as: user1 user2 user3 I want to apply id on each of them and get something like: uid=100(user1) gid=5(g1) groups=5(g1),6(g6),7(g10) . . How can I achieve this? Please note that the list is the output of another…
18
votes
3 answers

curl .gz file and pipe it for decompression

I am trying to download some .gz files (N.B. not .tar.gz ones) from given URLs and decompress them to overwrite existing files, if any. For each individual download, I tried the following: curl -O $URL | gunzip -f However, this did not work as it…
skyork
  • 441
18
votes
4 answers

build command by concatenating string in bash

I have a bash script that builds a command-line in a string based on some parameters before executing it in one go. The parts that are concatenated to the command string are supposed to be separated by pipes to facilitate a "streaming" of data…
Mr. Developerdude
  • 821
  • 2
  • 7
  • 17
1
2 3
13 14