Chains the standard streams of a series of commands

learn more… | top users | synonyms

5
votes
1answer
1k views

background process pipe-input

if i want to display "aaa" on screen: (1)$: echo aaa | cat ... works OK (2)$: echo aaa | ( cat ) ... works OK (3)$: echo aaa | ( cat & ) ... NOT working ...
0
votes
3answers
468 views

pass piped variable to perl oneliner

if you have something like: find . -d -maxdepth 1 | wc -l | perl ... what ways do you have to tell perl to take this variable that's coming its way and substract 1? I try to substract 1 since find ...
3
votes
3answers
648 views

Does one end of a pipe have both read and write fd?

As far as I understood one end of a pipe has both read and write fd's and the other end also has read and write fd's. Thats why when we are writing using fd[1], we are closing the read end e.g. ...
3
votes
2answers
384 views

Read data from a pipe for a certain amount of time (in seconds)

Is there an easy way to create a pipe that only lasts for a given amount of wall time? I want to be able to take a "snapshot" of what's being written STDOUT for a period of time (rather than bytes or ...
0
votes
1answer
459 views

ps | grep shows bad output in subshell with jobs running in the background

I am using bash. I have a file named "a2draw" that contains only 1 line: sleep 99999 I start it using this command: bash a2draw & Now, I know and understand the trick with square bracket ...
1
vote
0answers
286 views

avconv/ffmpeg output through /dev/ttyAMA0

I tried to pipe streaming video from video4linux2 webcam connected to a Raspberry Pi through /dev/ttyAMA0 to a computer using an Arduino as a intermediary. First of all, is it possible? Because I was ...
28
votes
4answers
9k views

What are the advantages of using named pipe over unnamed pipe?

I was reviewing a set of interview questions that are asked from a unix admin; I found a topic called "named pipe". I googled the topic; to some extent I have been able to understand it :- named ...
4
votes
3answers
1k views

Races when piping two commands to a named pipe

I want to have one process reading from a named pipe that receives data from multiple sources: $ mkfifo /tmp/p But I can't figure out how to get it to work consistently. First Scenario - this ...
0
votes
1answer
283 views

Can someone provide an xargs example piping mysql query data into another command?

Can someone provide an example for the command xargs? I want to do a mysql query to return the ID field of a column then feed that result into xargs into another command say mysql query delete. How ...
1
vote
1answer
138 views

What rules govern the parent-child relationship of processes launched by shell across a pipe?

#!/bin/ksh # start_service: start the service my_server_executable 2>&1 | my_pipe_following_shell_script & exit 0 After I run the above start_service script from command line, it is ...
10
votes
1answer
1k views

What are guarantees for concurrent writes into a named pipe?

For example, I created a named pipe like the following: mknod myPipe p And I read from it from some process (for example, some server). For example purposes, I used tail: tail -f myPipe If ...
3
votes
4answers
4k views

Piping output to text file within a for loop

I'm trying to do the following within a for loop: Find files that satisfy a condition Echo the name of the files to a log file. Gzip the file. I can get the script to find the files and echo their ...
1
vote
1answer
83 views

Encrypting import's output with gpg at the same time

The import command saves screenshot in a file. Is there a way to encrypt that file at the same time using gpg, without saving the image file first? gpg accepts input from stdin but it seems that ...
7
votes
3answers
2k views

tee + cat: use an output several times and then concatenate results

If I call some command, for instance an echo I can use the results from that command in several other commands with tee. Example: echo "Hello world!" | tee >(command1) >(command2) ...
4
votes
0answers
78 views

Combing head and tail in a single call via pipe [duplicate]

On a regular basis, I am piping the output of some program to either head or tail. Now, suppose that I want to see the first AND last 10 lines of piped output, such that I could do something like ...
1
vote
2answers
2k views

Why does pipe not work with cat and locate?

I am trying to perform this: locate pg_type.h | cat But this command simply does nothing different than locate pg_type.h What should I change ? I want to perform cat pg_type.h wherever pg_type.h ...
2
votes
1answer
117 views

Stderr of piped shell scripts isn't always displayed

I piped my own shell scripts for some testing and accidentally noticed something strange. Namely, the stderr of those piped processes isn't always displayed on the screen. I simplified the scripts ...
2
votes
1answer
2k views

Bash vs ksh pipes

I am stuck with some problems with my scripts in ksh. FWIW the problem which I am unable to overcome is that when I use a structure such as this command | while read VAR1 do many.commands using ...
2
votes
3answers
601 views

How to stop `grep` from truncating pipe output

Is there any way to have an echo at the end of a pipe simply append to the current output rather than removing it all? For example, how can I keep the output for my cat and grep and add "END OF ...
0
votes
2answers
98 views

Piping commands together in unix

How do I pipe the output of one command to another in unix? For example, If I want to pipe the output of sort to tail, how would I do that?
1
vote
1answer
357 views

Managing the output streams of many subprocesses with deadlocks

I have a Python script that does more or less this current_tasks = TaskManager() MAXPROCS = 8 while len(outstanding_tasks) > 0: if len(current_tasks.running) < MAXPROCS: ...
10
votes
2answers
4k views

Pseudo files for temporary data

I often want to feed relatively short string data (could be several lines though) to commandline programs which accept only input from files (e.g. wdiff) in a repeated fashion. Sure I can create one ...
3
votes
4answers
2k views

How to pipe the stdout to a file if the current command is already being piped through gzip

So I have this command I need to run then disown: innobackupex-1.5.1 --user=root --password=**** --stream=tar ./ | gzip - > /data/myfile.tar.gz How do I pipe any output to a file? adding ...
3
votes
1answer
52 views

Emulating a file

I have certain application that opens a file with given path (presumably with fopen or derivative), reads the file, possibly writes to it and closes it. I have no control over this application other ...
3
votes
1answer
194 views

No output from inotifywait | awk

I'm attempting to use part of a one-liner found here: Script to monitor folder for new files? When I try the following procedure I get no output whatsoever and I cannot figure out why. In terminal ...
2
votes
1answer
280 views

How to copy the output of pacman-color into a file and to display the output with the colors in the terminal

Originally I used pacman, not pacman-color and I copied the output into a file and I displayed the output in the terminal with the following command : pacman -Syu | tee file.log Unfortunately, it ...
6
votes
2answers
2k views

Why does Subversion give a broken pipe error when piped into head?

If I do a svn log | head after the tenth line of output I get an error message: svn: Write error: Broken pipe What's going on here? I haven't seen any other command do this when used with head. ...
2
votes
4answers
164 views

store and execute redirection/piped command in script

How do you store, and later execute, a command with redirection and and a pipe? (And is it the pipe, or the redirection, or both, that's causing my problem?) I tried to print the urxvt version in a ...
9
votes
2answers
2k views

echo vs <<<, or Useless Use of echo in Bash Award?

By now the Useless Use of cat Award is very well known, and there's also a mention of a Useless Use of echo (not relevant for this question). I'm wondering if there should be a "Useless Use of echo in ...
4
votes
1answer
576 views

Ksh loses data after piping 16K bytes

I recently found that ksh may lose some data after printing more than 16K bytes to the stdout if it is blocked for a couple of seconds. This test.sh script prints out 257*64 (16448) bytes: ...
1
vote
0answers
274 views

Why does this pipeline get SIGTTIN?

When I run the command for i in *.log; do cat "$i" | sort; done | more, the pipeline gets a SIGTTIN signal and is stopped. bash$ for i in *.log; do cat "$i" | sort; done | more ### (one screenful of ...
2
votes
1answer
407 views

Make stdout and stderr be buffered by the same buffer

Is it possible to force glibc to use the same buffer for stdout and stderr? If I tee the both outputs: ./tests/tests 2>&1 | tee log I get mixed messages (i.e. messages are ordered inside ...
8
votes
1answer
934 views

How to copy from/to the tmux 'clipboard' with shell pipes?

When working in a shell environment I run fairly often into the need to copy 'intermediate pipe output' around (eg. from/to already running editors, to other shells, other machines, etc.). When in a ...
2
votes
3answers
3k views

Count running processes using wc and ps

I tried using ps r > log | wc log but this returns Ambiguous output redirect.. Can someone explain why and provide another solution?
1
vote
1answer
107 views

What is the difference between who > lp and who | lp?

Why does the who > lp creates a file but who | lp leads the output to program lp? What is the underlying principle behind these two simple commands? Can somebody explain it with an example?
0
votes
2answers
124 views

Why is there no critical section in the pipe?

Why is there no critical section in the pipe? For example, as in shared memory. In pipe have general data, which in common use in joint processes, but in the shared memory also have general data, ...
6
votes
2answers
913 views

Pipe Password to Application When Asked

The following should be done in a bash script: curl --digest --user schmijos https://bitbucket.org/u/p/get/tip.zip -o tip.zip How can I automatically submit a password to curl when it asks for it? ...
15
votes
1answer
458 views

Make program first read from pipe, then from keyboard

Consider the interactive program interactive. I have to run this program fairly frequently, and each time I run it the first few commands are the same. Obviously, having to type those commands over ...
2
votes
2answers
508 views

Mplayer controls when using stdin playlists

I ran across this post: How can I retain the console input in mplayer when reading from stdin? But the answer there doesn't work for me. (and I can't comment due to not enough rep) I'm running the ...
6
votes
1answer
469 views

Why mkfifo behaves like a LIFO?

If i do. mkfifo /tmp/a echo 'one'>/tmp/a in the while from another terminal echo 'two'>/tmp/a and from a third terminal more /tmp/a Why i obtain as output of the last command this? ...
20
votes
5answers
6k views

How to make bidirectional pipe between two programs?

Everyone knows how to make unidirectional pipe between two programs (bind stdout of first one and stdin of second one): first | second. But how to make bidirectional pipe, i.e. cross-bind stdin and ...
9
votes
2answers
258 views

How a piped shell programs balance their output/input rates? [duplicate]

Possible Duplicate: Bash while loop and reading from pipe I come from web programming background, and find myself interested in one peculiarity of using a local shell. I understand that ...
1
vote
2answers
590 views

Print/Tee to console without passing output to pipe

Is there a way to print or tee one thing to the console and still pass something else through to the next pipe? Something like: echo dog | printOrWhatnot "PUTTING MY THING DOWN" | sed 's/dog/cat/g' | ...
2
votes
1answer
68 views

Changing compression in memory

I have some large files that I need to change the compression type of for input to a program--I need to unrar them and then gzip (or bzip2) them. However, they're highly compressed files and I don't ...
2
votes
3answers
733 views

How to make wc interpret standard in as a file list

I know that there are other ways to go about this, but I'm looking to be able to make wc interpret stdin as a file name or list of file names. For example, ls JP*/std* | wc would work the same as ...
7
votes
4answers
711 views

Creating a single output stream out of three other streams produced in parallel

I have three kinds of data that are in different formats; for each data type, there is a Python script that transforms it into a single unified format. This Python script is slow and CPU-bound (to a ...
2
votes
1answer
214 views

Piped command changes PID

I created a (Debian) init Script for an executable Jar file: [...] NAME=NameOfMyShellScript DAEMON="/usr/share/myApp/bin/$NAME" USER="myUser" PIDFILE="/usr/share/myApp/run/$NAME.pid" EXTRA_ARGS=" -c ...
3
votes
3answers
1k views

Bash while loop and reading from pipe

I have a Windows command-line program that I'm running in a Bash script in Ubuntu via wine. The Bash script basically looks like this: wine myprogram.exe | while read line do # Process line done ...
10
votes
2answers
11k views

Bash: How to read one line at a time from output of a command?

I am trying to read the output of a command in bash using a while loop. while read -r line do echo "$line" done <<< $(find . -type f) The output I got ranveer@ranveer:~/tmp$ bash ...
2
votes
0answers
350 views

How to redirect and use the framebuffer?

I need to work on the framebuffer to record what is being rendered. Now, I figure out how to convert the framebuffer in an image, I'm currently unable to obtain a constant stream of data from the fb ...