Skip to main content

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.

Filter by
Sorted by
Tagged with
294 votes
5 answers
89k views

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 | ...
Jeremy Powell's user avatar
133 votes
6 answers
63k views

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).
Paweł Gościcki's user avatar
130 votes
7 answers
38k views

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 ...
Jonathan Day's user avatar
  • 1,611
129 votes
5 answers
341k views

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 ). ...
Mihai Rotaru's user avatar
  • 2,909
90 votes
8 answers
118k views

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 ...
Ian Mackinnon's user avatar
88 votes
4 answers
76k views

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....
Foo Bar's user avatar
  • 1,500
80 votes
5 answers
31k views

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 | ...
Frédéric Grosshans's user avatar
72 votes
9 answers
121k views

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 ...
Narin's user avatar
  • 823
59 votes
6 answers
40k views

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 ...
Jonas Sourlier's user avatar
55 votes
9 answers
34k views

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 ...
Adrian Panasiuk's user avatar
51 votes
8 answers
13k views

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 ...
arunkumar's user avatar
  • 623
50 votes
4 answers
18k views

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's user avatar
48 votes
3 answers
15k views

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's user avatar
  • 693
47 votes
3 answers
25k views

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 ...
FatalError's user avatar
  • 2,173
46 votes
3 answers
30k views

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 ...
Nicolas Raoul's user avatar
45 votes
3 answers
129k views

Howto pipe: cp | tar | gzip without creating intermediary files?

Can anyone tell me if it's possible to pipe | this without having to create a physical file anywhere between A and B.tar.gz? This is what I'm trying to do: File A Rename A to B Tar B.tar gzip -9 B....
user avatar
43 votes
4 answers
163k views

How can I pipe output of ffmpeg to ffplay?

How can I pipe the output of ffmpeg to ffplay? At the moment I use a workaround in bash : mkfifo spam (ffplay spam 2> /dev/null &) ; capture /dev/stdout | ffmpeg -i - spam
wim's user avatar
  • 3,197
35 votes
1 answer
34k views

how to escape pipe symbol | in bat scripts?

I need to echo commad usage like this in batch script named command.bat command.bat on|off I cant use echo %0 on|off I know I can use echo "%0 on|off" but it puts quotes along Is there any ...
Prashant Bhate's user avatar
34 votes
3 answers
12k views

Why is xargs necessary?

Suppose I want to remove all files in a directory except for one named "notes.txt". I would do this with the pipeline, ls | grep -v "notes.txt" | xargs rm. Why do I need xargs if the output of the ...
seewalker's user avatar
  • 713
33 votes
5 answers
82k views

Downloading Youtube videos in a text file...?

If you are familiar to Linux, see the following script... I have a text file with a (list.txt) of Youtube URLs separated by new line... and I use cat list.txt | youtube-dl -f best to download all ...
user avatar
33 votes
3 answers
47k views

Using -replace on pipes in powershell

I want to test out a replace before I use it, so I'm trying to write a quick online command to see what the output is. However, I'm not sure what the syntax is. What I want to do is something like ...
David says Reinstate Monica's user avatar
32 votes
5 answers
61k views

Passing two arguments to a command using pipes

Usually, we only need to pass one argument: echo abc | cat echo abc | cat some_file - echo abc | cat - some_file Is there a way to pass two arguments? Something like {echo abc , echo xyz} | cat cat ...
goweon's user avatar
  • 1,753
30 votes
3 answers
26k views

Pipe gunzip and mysql to gunzip a dump and import it

I have a .gz sql dump file (example: foo.sql.gz) that i want import in my database with the classic mysql command. gunzip -c foo.sql.gz > foo.sql mysql -uroot -ppassword foo < foo.sql foo is ...
apelliciari's user avatar
30 votes
4 answers
44k views

With regards to piping commands, what are the greater than (>) and less than (<) symbols called?

On linux at least, and I think windows/dos shell too you can use > to "pipe" output into a file. Something like: cat myfile.txt > mightAsWellCP.txt What is that piece of syntax sugar called? ...
Mikey's user avatar
  • 1,129
29 votes
6 answers
21k views

Make a pipe conditional on non-empty return

Is there a way to pipe the output of one function to another, but only if there is an output?
Tgr's user avatar
  • 3,063
29 votes
3 answers
29k views

How do I pipe output to date -d "value"?

I have a date like 2014-01-30 05:04:27 GMT, and if I run date -d "2014-01-30 05:04:27 GMT", the output is in my server's timezone (Thu Jan 30 16:04:27 EST 2014). With the use of grep and cut,...
LeigerGaming's user avatar
29 votes
3 answers
8k views

What does the last "-" (hyphen) mean in options of `bash`?

In this tutorial we need to execute the following command: # curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash - What does the last - (hyphen) after bash mean? I've seen a lot of ...
Omar BISTAMI's user avatar
29 votes
3 answers
24k views

Setting pipefail for a single piped command

I need to execute a number of piped shell commands from a non-BASH script (namely PHP script) like these: command1 | command2 | command3 so that, if command1 fails with a non-zero exit code, each ...
Desmond Hume's user avatar
  • 2,630
28 votes
3 answers
39k views

In windows, can I redirect stdout to a (named) pipe in command line?

Is there a way to redirect the standard output of a process in Win32 console to a named pipe? Named pipes are built in to Windows and while they would be an useful concept, I've never seen them used ...
n611x007's user avatar
  • 6,416
25 votes
4 answers
45k views

Why does this not work? "ls *.txt | xargs cat > all.txt" (all files into single txt document)

Why does this not work? ls *.txt | xargs cat > all.txt (I want to join the contents of all text files into a single 'all.txt' file.) find with -exec should also work, but I would really like to ...
ajo's user avatar
  • 915
23 votes
5 answers
68k views

What does the linux pipe symbol "|" do? [duplicate]

Here is a command that sorts files in a folder in reverse order ls | sort -r What does the | symbol in that command do? What I'm really looking for here is high level (easy to understand) ...
ccalvert's user avatar
  • 359
23 votes
2 answers
8k views

What is the magic separator between filenames in ls output?

The output of ls (with no arguments) appears to separate filenames with linebreaks. Evidence: ls | grep foo works as expected, with grep treating each filename as a separate line of input. ls > ...
Chris B's user avatar
  • 333
22 votes
7 answers
72k views

Advantages of cat'ing file and piping to grep

Are there any additional advantages of cat'ing a file and piping it to grep, besides convenience? The convenience being that, when I retrieve commands such as those below from my history, the cursor ...
Dexygen's user avatar
  • 325
21 votes
3 answers
16k views

Windows how to redirect file parameter to stdout? (Windows equivalent of `/dev/stdout`)

Windows console: Tool A can write binary data to a file, but has no option for telling it to use stdout. Tool B can read binary data from stdin and process the info in it. How can I get the output ...
Jeroen Wiert Pluimers's user avatar
20 votes
2 answers
60k views

pipe and stdin redirection to cat

Why does echo "hello world" | cat works while cat < echo "hello world" does not? My (incorrect) intuition is that pipe would redirect stdout to cat as stdin.
irritable_phd_syndrome's user avatar
20 votes
4 answers
14k views

real windows equivalent to cat *stdin*

Under cmd is there a windows equivalent to the posix command cat ? cat all by itself no filenames, no switches. I just want something that copies stdin to stdout until it hits EOF. it's not a hard ...
user313114's user avatar
19 votes
5 answers
11k views

How to a open a file in vim using pipe

I get to use the locate command extremely often. So if I run the following command. locate updatedb | head -1 Then it gives me the O/p /usr/updatedb.conf I wonder if there is any such command ...
Krishna's user avatar
  • 422
19 votes
7 answers
11k views

how to beep on tail -f event

I want my PC to make a system beep on every tail event I have the following command tail -f development.log | grep "something rare" is there an easy way like pipeing it to somthing that beeps? ...
Jakob Cosoroaba's user avatar
19 votes
5 answers
150k views

Get response body and show HTTP code by curl

I have endpoint which returns JSON (response body). I need get by curl the response body and process it (for example using jq). It works: response=$(curl -s https://swapi.dev/api/people/1?format=json) ...
mkczyk's user avatar
  • 635
18 votes
3 answers
42k views

Netcat/socat behavior with piping and UDP?

I guess this is close to linux - Netcat stops listening for UDP traffic - Super User, but I thought I'd better ask anyways As far as versions of netcat I'm using Ubuntu 11.04 and the default netcat ...
sdaau's user avatar
  • 5,718
17 votes
4 answers
5k views

What does "2>&1" do when posted BEFORE 1>x?

I know what this command does: command 1>/dev/null 2>&1 But what, if anything, does the following do? command 2>&1 1>/dev/null I still see standard error output with the second ...
hanshenrik's user avatar
  • 1,735
17 votes
3 answers
8k views

Is pipe ( | ) a command?

As I understand it, pipe ( | ) takes the standard output of one process and passes it as standard input into another process. But I want to know if pipe ( | ) is considered a command like ls, grep ...
User82949B's user avatar
17 votes
1 answer
9k views

Rendering HTML from a pipe

I would like to be able to generate HTML then pipe it to a program which will render it, something like this: for i in 1 2 3 do for j in a b c do echo "<table border="1"><tr&...
Barton Chittenden's user avatar
17 votes
1 answer
37k views

What are reasons for local Windows named-pipes to fail?

I've been working hard on this one all day and I'm stuck. This morning our asian collegues called me because a SolidWorks addin for our product data management system could not communicate with the ...
user152700's user avatar
15 votes
3 answers
24k views

Pipe file content into PowerShell command without loading the entire file to memory

I've recently started using PowerShell, hoping to never miss Bash again. I want to restore an instance of a PostgreSQL database. In Bash, or in the old command prompt, I would type: psql --...
zmbq's user avatar
  • 966
15 votes
1 answer
5k views

Is backwards redirection the same as a pipe?

In Linux if you type sort < txtfile is that the same thing as cat txtfile | sort
tony_sid's user avatar
  • 14.5k
14 votes
4 answers
17k views

How to pipe awk output (with periodic, continuous input) to output file?

I am trying to write a command that pipes the continuous output of a free command (run every second) to an awk command that parses a specific value (available free memory) and outputs this to a file ...
Mark's user avatar
  • 370
14 votes
1 answer
13k views

How to pipeline stderr in cmd.exe?

Some programs would prefer to output the help message in stderr. I want to search the help message with grep command, xx /? | grep regex? How could i do this?
Jichao's user avatar
  • 7,570
14 votes
3 answers
10k views

Does pipe have to write temporary file?

I found that if I transfer a great amount of data between two processes via pipe, some temporary file will be created by linux in /tmp directory. If the pipe operation succeeds, the corresponding ...
solotim's user avatar
  • 285
13 votes
4 answers
37k views

I would like to pipe output of find into input list of scp, how?

I'm a novice linux user and I am trying to send a long list of files from one computer to another. The argument list is too long, so I am using find. I am having trouble setting up the expression, ...
phoganuci's user avatar
  • 265

1
2 3 4 5
9