Chains the standard streams of a series of commands

learn more… | top users | synonyms

14
votes
4answers
471 views

How can I implement a circular flow of data among interconnected commands?

I know of two types how commands can be connected with each other: by using a Pipe (putting std-output into std-input of the next command). by using a Tee (splice the output into many ...
4
votes
1answer
69 views

How to perform the watch command onto expression with pipes?

I learned today the wonderful shuf command: ls | shuf shows me a listing of the working direcotry, but thanks to shuf each time I execute this piped command expression with another order. So I ...
1
vote
2answers
41 views

pipe in shell with redirection

My understanding is that a pipe in shell like a | b redirects b's stdin to a's stdout. However, I tried ls | less < somefile, the behavior is very strange. less shows the output of ls concatenated ...
0
votes
1answer
32 views

Is it possible to link file to an output of command line? [duplicate]

I want to create symlink, or a pipe, or something else that could be used in lieu of a file. I want that pseudo-file to execute a command and output of that command should become the contents of that ...
1
vote
1answer
31 views

Only pipe on Success [duplicate]

Is there a way in the Linux command line, to only have a command pipe its output to another, when the command didn't fail? $ cmda | cmdb I would like it, so when cmda returns a status code other ...
3
votes
1answer
29 views

why does the output of xargs -n2 applied to the same number of arguments different whether piped or from keyboard?

when I execute xargs -n2, enter x x x x x and hit Enter, I get only 4 x back: $ xargs -n2 x x x x x x x x x But, when I pipe the x x x x x into the same command, I get the same amount of x back: ...
3
votes
4answers
524 views

tar a result of wget

I want to wget a file and tar it, in one command, I guess it is simple but I can't get it done. I tried several things. wget <url> | tar -cvz file.gz.tar - tar -cvzf file.tar `wget ...
1
vote
1answer
37 views

How does 'bash' or 'gnome-terminal' print user and path information? [closed]

I am wondering if there is a different mechanism between printing user and path information(e.g. "guest:~/home/guest$") and command outputs. When I try to PIPE stdin and stdout of "bash", I can only ...
0
votes
1answer
44 views

Can a command in a shell pipeline determine the tty characteristics of its context?

I have a bash script that columnizes a list of items. By default it will guess at the number of columns to output, based on the terminal width as reported by stty size. But when the script is in a ...
4
votes
4answers
330 views

How to fill a file with a stream from /dev/urandom with a specified number of lines ?

I am trying to fill a file with a sequence of random 0 and 1s with a user-defined number of lines and number of characters per line. the first step is to get a random stream of 0 and 1s: cat ...
1
vote
1answer
26 views

Using SMB to pipe contents of file to local command on local machine

Here is my situation. I have a 100gig file on a remote server, what I need to do is connect to that machine and zcat that file and pipe the output of zcat to a command on a local machine... I was ...
0
votes
1answer
29 views

Print nth pipeline command in bash

In bash, the PIPESTATUS array holds the return values of commands in a pipeline. Suppose that in the pipeline cmd1 | cmd2 | cmd3, the second command returns an error. Checking PIPESTATUS gives the ...
1
vote
1answer
35 views

Saving colored output regardless of the source

How can I save colored output to a file regardless of the source when the sources turn coloring off if they detect their stdout isn't a terminal?
3
votes
1answer
55 views

rlwrap -z pipeto: piping output through pagers

I am using rlwrap to colorize prompt in asterisk CLI: rlwrap -s 99999 -a -pRED /usr/sbin/asterisk -r I read in man rlwrap that I can also use rlwrap -z pipeto to pipe output through a ...
0
votes
0answers
19 views

Grep not writing output until end of input [duplicate]

I have some script that is taking a long time, and producing a lot of output. I want to send the full output to one file, and pick out some specific lines to be directed to another file. Since it ...
0
votes
2answers
48 views

Not getting grep with a variable

I am assigning a variable to echo command which generates a random number. For eg: n=$(echo $(( (RANDOM%6) +1)). I have to grep this variable in /etc/passwd. So, my syntax reads like: n=$(echo $(( ...
20
votes
4answers
832 views

Is it possible to redirect the output of a command into more than one command?

As far as I know, I can use the tee command to split the standard output onto the screen and further files: command -option1 -option2 argument | tee file1 file2 file3 Is it possible to redirect ...
0
votes
2answers
49 views

Will “tail -100 | sed -n 1p” only read one line?

I'm searching backwards from the end of a file, it's probably easiest to explain by showing my code: enough=0 numberOfLines=100 fileName="/path/to.file" # Tail the last $numberOfLines lines; if the ...
0
votes
3answers
37 views

grep randomly appearing and disappearing in ps aux (ps aux | grep python) [duplicate]

This isn't an actual problem - but more of a curious question, when I run while true; do ps aux | grep abc; echo done; done I get the following: user 29733 0.0 0.0 11748 924 pts/1 R+ ...
3
votes
1answer
25 views

Pipe command output to Yad and also log the output to a logfile

Need to have the process of command typically an update to be shown using yad and at the same time log all the output to a given log file set up. This is what I have apt-get update | yad ...
3
votes
2answers
87 views

Named pipes: several experiments leads to confusion [closed]

I've come across various articles and SO questions and I am still confused about something that I use on daily basis, but never realized how confusing it can be. I am experimenting with (named) pipes ...
2
votes
4answers
54 views

Completely buffer command output before piping to another command?

Is there a way to only execute a command after another is done without a temp file? I have one longer running command and another command that formats the output and sends it to a HTTP server using ...
9
votes
4answers
708 views

Spaces next to pipes

I've seen history | grep blah and history |grep blah; and history|grep blah also works, though no one ever seems to use it. Is there any significance in the spaces (e.g. piping to/from different ...
0
votes
1answer
34 views

explain this shell command with redirection and pipe

I can understand the statements like. bzip2 --version >/tmp/list_right 2>/tmp/list_error bzip2 --version >/tmp/list 2>&1 But I don't understand the statement: bzip2 --version ...
0
votes
1answer
43 views

Combine the output of while loop into tar

I'm trying to create a script that mysqldumps all my databases, creating an individual .sql file for each database and combines the output into backup-DATE.tar.gz. I've gotten as far as being able to ...
0
votes
1answer
36 views

Saving from arecord on a raspberry pi across a network to a mac

I've currently got a usb mic plugged into a Raspberry Pi B+ and am using the following code to record data: arecord --buffer-time=5000000 -D plughw:1,0 -f cd -t raw | lame -r - stream.mp3 I then ...
3
votes
1answer
254 views

Chaining pipe | with &&

I have this command where I want to filter make output: cd /app && make && sudo nginx -g 'daemon off;' What is the correct way to insert make | pv -q -L 100 here?
3
votes
1answer
147 views

eval limitation with piped commands

We have a shell script that builds a long piped command chain in a variable and executes it with eval (the following code is simplified to the essential): cmd="cat /some/files | grep -v \"this\" | ...
12
votes
3answers
457 views

No colored output in less for the ls command

If I run ls I get colored output which I find pretty handy for quickly getting a glance of the kind of file. When I try to pipe it to less even with the -r and -R flags the coloring always get lost. I ...
0
votes
3answers
47 views

Reuse output from command 1 in command 2 using a pipe

I've got a command in linux which returns a list of numbers. Now I need this numbers to form a directory path and cat the file located at that path. For example: myCommand returns: 1 10 30 40 And ...
1
vote
1answer
118 views

How to pipe scp/ssh file transfer(pull) through tar (remote->local transfer initiated from local machine)

I would like to pipe an scp pull operation(sample without tar below) through tar, so that only one tar file is written for about 10 directories: user@localhost:/home/user> scp -r ...
1
vote
1answer
31 views

Non-block poll from two pipes?

Here is what I want to do.. mkfifo infrequentlog frequentlog sort -m infrequentlog frequentlog > mylog funcA > infrequentlog funcB > frequentlog So that when monitor tail, I can see the ...
4
votes
2answers
55 views

How can I catch a command exit code for later, in a Makefile?

I have a makefile, with a test suite target, like so: rcheck: foo This shows the output from the foo command on stdout, and returns an exit code from foo which is handled by make as normal. ...
2
votes
1answer
57 views

Bash Named Pipe - Atomic Reading

I have set up one script to write to a named pipe, then four scripts to read the named pipe. For most of the entries, there are no problems, but when there is little processing to be done on the ...
0
votes
0answers
25 views

What to use instead of `buffer` for 1GB buffer?

buffer(1) seems to be old-ish and have hard-coded values preventing it to cache large amount of data. $ buffer -m 1G max_shmem 1 too low // it doesn't even understand gigabytes $ buffer -m 1000M ...
1
vote
1answer
32 views

pipe a file to a slow processing script question

Let's say I have a very large file and I want to process every line in that file by piping it to script. cat large_file.txt | python processor.py I'm not completely sure how the above operation ...
2
votes
1answer
25 views

pipe speed benchmark with machine readable output

I'm looking for a tool similar to pv which is producing machine readable output. And i cant believe that nobody did it bevore... I looked at the manpages of pv, pipemeter, dd and cpipe but all these ...
5
votes
3answers
111 views

Split an input for different command and combine the result

I know how to combine the result of different command paste -t',' <(commanda) <(commandb) I know pipe same input to different command cat myfile | tee >(commanda) >(commandb) Now ...
1
vote
1answer
105 views

Why does bash output data instead of executing, when a script is piped?

I'm running the following script on Ubuntu 14.04: #!/bin/bash apt-get purge -y nginx apt-get install -y nginx date When I run it like cat /tmp/script | bash, apt-get starts installing, then ...
20
votes
2answers
1k views

Pipes, how do data flow in a pipeline?

I don't understand how the data flows in the pipeline and hope someone could clarify what is going on there. I thought a pipeline of commands processes files (text, arrays of strings) in line by line ...
0
votes
2answers
71 views

ps output / pipeline execution order

I run ps aux | grep somethinghere. The output shows the grep somethinghere as a running process. My question is, shouldn't ps aux finish first, then grep somethinghere run on its output? Maybe there ...
4
votes
3answers
235 views

Piping a script with “read” to bash

I need to run a script by piping it through bash with wget(rather than running it directly with bash). $ wget -O - http://example.com/my-script.sh | bash It's not working because my script has read ...
1
vote
3answers
59 views

Tailing log files in two different hosts

I'm trying to tail two log files in different hosts and use the merged output as a single one. ssh HOST_1 "tail -f MY_LOG_FILE" I'm also using mkfifo to create a named pipe. mkfifo MY_PIPE The ...
3
votes
2answers
108 views

How to use tee to capture STDOUT from a code block to a filename defined within the block?

I want to send STDOUT for a script block to a file which name is defined by a variable within the block. However, when I use tee, it seems the variable outside the block doesn't exist anymore. Without ...
1
vote
1answer
51 views

Output Redirection

I am using the tee command to output the compilation errors of a program into a file along with the terminal. gcc hello.c | tee file.txt This is the command I have used. The compilation errors are ...
0
votes
1answer
33 views

exit status and no output

I have a command such that bar > /dev/null and I want to know the exit status of bar. I read some posts su about ${PIPESTATUS[0]} but this works when one pipes the output via | and I can't make ...
2
votes
2answers
71 views

What exactly is the difference between pipes and streams?

I read about pipes and streams and I’m still confused on how it’s implemented. A program is started and it reads data from “standard input” stream (stdin), which is where the keyboard sends data to. ...
0
votes
0answers
30 views

Pipe to `ls` Not Working as Expected [duplicate]

When I issue: [dave@dhost ~]$ which tar | ls -l I get the output of ls -l of the pwd. I expected to get: -rwxr-xr-x. 1 root root 395472 Feb 21 2013 /bin/tar Why doesn't the pipe work as I ...
4
votes
3answers
185 views

Using | pipe character from a $variable makes it treat as just another argument in bash; how to escape it?

I have a bash script like this export pipedargument="| sort -n" ls $pipedargument But it gives the error ls: |: No such file or directory ls: sort: No such file or directory It seems to be ...
2
votes
2answers
112 views

Feed source command with a pipe

Previously I used source command like this: source file_name But what I'm trying to do is this: echo something | source Which doesn't work.