Questions tagged [pipe]

Pipes or named pipes are a feature of the POSIX standard that allow separate processes to communicate with each other without having been designed explicitly to work together.

Pipes or named pipes are a feature of the POSIX standard that allow separate processes to communicate with each other without having been designed explicitly to work together.

Pipe can also refer to the character produced by pressing shift+backspace. It looks like this: |

419 questions
301
votes
5 answers

Getting colored results when using a pipe from grep to less

I use the --colour option of grep a lot, but I often use less as well. How can I pipe grep results to less and still preserve the coloring. (Or is that possible?) grep "search-string" -R * --colour | less EDIT: I'm looking for a direct solution…
150
votes
6 answers

Preserve colors while piping to tee

ls -l --color=auto | tee output.log Without pipe/tee it's colored. How can I make it so that it stays colored while using tee (can be colored only on the screen, I don't care about colors in logs).
134
votes
6 answers

How to pipe command output to other commands?

Example: ls | echo prints nothing ( a blank line, actually ). I'd expect it to print a list of files. ls | grep 'foo', on the other hand, works as expected ( prints files with 'foo' in their name ). What I do in these situations is something like: …
Mihai Rotaru
  • 2,979
133
votes
7 answers

How can I save the current contents of less to a file?

If I've piped the results of a command to less and then decided that I want to save the contents to a file, is this possible? I've tried setting a mark a at the end of the buffer, and then returning to the top and using |avi to send the whole…
Jonathan Day
  • 1,641
91
votes
8 answers

How to suppress cUrl's progress meter when redirecting the output?

I'm trying to print just the verbose sections of a cURL request (which are sent to stderr) from the bash shell. But when I redirect stdout like this: curl -v http://somehost/somepage > /dev/null Some sort of results table appears in the middle of…
89
votes
4 answers

Why is piping 'dd' through gzip so much faster than a direct copy?

I wanted to backup a path from a computer in my network to another computer in the same network over a 100 Mbit/s line. For this I did dd if=/local/path of=/remote/path/in/local/network/backup.img which gave me a very low network transfer speed of…
Foo Bar
  • 1,560
81
votes
5 answers

How to rate-limit a pipe under linux?

Is there a filter which I could use to rate-limit a pipe on linux? If this exists, let call it rate-limit, I want to be able to type in a terminal something like cat /dev/urandom | rate-limit 3 -k | foo in order to send a a stream of random bytes…
Frédéric Grosshans
  • 1,385
  • 2
  • 10
  • 10
74
votes
9 answers

Can I use pipe output as a shell script argument?

Suppose I have a bash shell script called Myscript.sh that need one argument as input. But I want the content of the text file called text.txt to be that argument. I have tried this but it does not work: cat text.txt | ./Myscript.sh Is there a way…
Narin
  • 843
61
votes
6 answers

Why does Powershell silently convert a string array with one item to a string

Consider the following Powershell script, which searches for folders in C:\ with a 'og' in their name: PS C:\> (ls | %{$_.Name} | ?{$_.Contains("og")}) PerfLogs Program Files setup.log Now I narrow down the search to get only one item: PS C:\>…
56
votes
9 answers

Bash: create anonymous fifo

We all know mkfifo and pipelines. The first one creates a named pipe, thus one has to select a name, most likely with mktemp and later remember to unlink. The other creates an anonymous pipe, no hassle with names and removal, but the ends of the…
55
votes
3 answers

Pipe to less but keep the highlighting

Is it possible to pipe output (e.g. dmesg) to a command like less (or equivalent) and keep the text highlighting used by the original command? example: on the left dmesg | less on the right dmesg
apoc
  • 763
53
votes
4 answers

Is there any way to keep text passed to head, tail, less, etc. to be colored?

Is there any way to keep colorization of text passed through pipe | to head, tail, less, etc.?
Timofey Gorshkov
  • 634
  • 1
  • 5
  • 8
53
votes
8 answers

What is the general consensus on "Useless use of cat"?

When I pipe multiple unix commands such as grep, sed, tr etc. I tend to specify the input file that is being processed using cat. So something like cat file | grep ... | awk ... | sed ... . But recently after a couple of comments left on my answers…
arunkumar
  • 643
51
votes
3 answers

Find what process is on the other end of a pipe

I'm trying to trace some odd behavior of a few processes and ran into a point I'm not sure how to trace past. The hung process, which I attached to using strace -p showed this: Process 7926 attached - interrupt to quit read(3, Okay, so it's…
FatalError
  • 2,233
  • 1
  • 18
  • 15
49
votes
3 answers

Comments in a multi-line bash command

This single-command BASH script file is difficult to understand, so I want to write a comment for each of the actions: echo 'foo' \ | sed 's/d/a/' \ | sed 's/e/b/' \ | sed 's/f/c/' \ > myfile (sed is just an example, actually it is a mix of…
Nicolas Raoul
  • 11,561
1
2 3
27 28