Questions tagged [piping]

This tag is appropriate for questions related to taking output from one operation and using it as input to a subsequent operation.

Questions concerning the chaining of command line calls where the output of one call is used as the input for another call should use this tag.

An example of piping would this Linux command:

grep -v bash /etc/passwd | grep -v nologin

The output from the first grep is piped into the second grep as input.

You can read more information about piping at Wikipedia.

351 questions
233
votes
3 answers

Piping both stdout and stderr in bash?

It seems that newer versions of bash have the &> operator, which (if I understand correctly), redirects both stdout and stderr to a file (&>> appends to the file instead, as Adrian clarified). What's the simplest way to achieve the same thing, but…
Andrew Ferrier
  • 16,664
  • 13
  • 47
  • 76
80
votes
4 answers

Why piping input to "read" only works when fed into "while read ..." construct?

I've been trying to read input into environment variables from program output like this: echo first second | read A B ; echo $A-$B And the result is: - Both A and B are always empty. I read about bash executing piped commands in sub-shell and…
huoneusto
  • 1,164
  • 1
  • 8
  • 19
61
votes
4 answers

Call another click command from a click command

I want to use some useful functions as commands. For that I am testing the click library. I defined my three original functions then decorated as click.command: import click import os, sys @click.command() @click.argument('content',…
kaligne
  • 3,098
  • 9
  • 34
  • 60
48
votes
4 answers

Chain arithmetic operators in dplyr with %>% pipe

I would like to understand why, in the the dplyr or magrittr package, and more specifically the chaining function %>% has some trouble with the basic operators +, -, *, and / Chaining takes the output of previous statement and feeds it as first…
agenis
  • 8,069
  • 5
  • 53
  • 102
43
votes
6 answers

Combining echo and cat on Unix

Really simple question, how do I combine echo and cat in the shell, I'm trying to write the contents of a file into another file with a prepended string? If /tmp/file looks like this: this is a test I want to run this: echo "PREPENDED STRING" cat…
Dan
  • 33,953
  • 24
  • 61
  • 87
37
votes
5 answers

putting a remote file into hadoop without copying it to local disk

I am writing a shell script to put data into hadoop as soon as they are generated. I can ssh to my master node, copy the files to a folder over there and then put them into hadoop. I am looking for a shell command to get rid of copying the file to…
reza
  • 1,188
  • 3
  • 17
  • 32
18
votes
2 answers

Creating batch file to start cygwin and execute specific command

I want to create a batch file thats start cygwin and executes a specific command (The command is to read a bash file and executes some command inside it). This is the batch file that I have developed, it works to some extent. the cygwin terminal…
manifertal
  • 199
  • 1
  • 1
  • 5
18
votes
5 answers

Making C code plot a graph automatically

I have written a program which writes a list of data to a '.dat' file with the intention of then plotting it separately using gnuplot. Is there a way of making my code plot it automatically? My output is of the form: x-coord analytic …
JMzance
  • 1,704
  • 4
  • 30
  • 49
17
votes
4 answers

Bash piping in OSX prompts command not found, sometimes

In the OSX terminal : du -h | sort -nr -bash:  sort: command not found which sort /usr/bin/sort The weird thing is: I tried reproducing the error and it seems to be totally random. My PATH…
wpp
  • 7,093
  • 4
  • 33
  • 65
16
votes
3 answers

Peter Piper piped a Python program - and lost all his unicode characters

I have a Python script that loads a web page using urllib2.urlopen, does some various magic, and spits out the results using print. We then run the program on Windows like so: python program.py > output.htm Here's the problem: The urlopen reads…
Mike Christensen
  • 88,082
  • 50
  • 208
  • 326
14
votes
1 answer

What is the difference between %>% and %,% in magrittr?

Github developmental version of magrittr includes some cool new function for piping but I do not exactly catch de difference between %>% and %,%. Is this only formal with %>% for value and %,% for functions, or there is some specific peculiarity?
BBrill
  • 1,922
  • 17
  • 17
13
votes
3 answers

Using fseek with a file pointer that points to stdin

Depending on command-line arguments, I'm setting a file pointer to point either towards a specified file or stdin (for the purpose of piping). I then pass this pointer around to a number of different functions to read from the file. Here is the…
Tyler Treat
  • 14,640
  • 15
  • 80
  • 115
13
votes
1 answer

Python capture all printed output

I am looking to write console based programs in python that can execute functions to perform generic tasks, pretty generic. Is it possible to capture everything written to the console by print calls in a function without needing to return a string,…
12
votes
1 answer

PowerShell ForEach / Piping confusion

I am using the TFS PowerTools Cmdlets in PowerShell to try to get at some information about Changesets and related WorkItems from my server. I have boiled the problem down to behavior I don't understand and I am hoping it is not TFS specific (so…
hexate
  • 123
  • 1
  • 1
  • 5
12
votes
2 answers

Batch: Escaping with caret

I've always hated batch and I still do, even for the most simple things I prefer C or PHP/Perl. But this time I could not go without it, ****sigh****. I wanted to redirect an echo command to an other command. For example: echo example | more but I…
Jori
  • 1,122
  • 2
  • 18
  • 36
1
2 3
23 24