Chains the standard streams of a series of commands

learn more… | top users | synonyms

3
votes
1answer
14 views

Round-tripping text through zip, unzip fails with 'extra bytes' error. On Mac OS X 10.10 [duplicate]

I'm trying to zip streaming text, and unzip it later. A minimal example is: echo "Hey, could you zip this for me?" | zip hello.zip - ; unzip -p hello.zip This fails, with following output. warning ...
2
votes
0answers
31 views

Deadlock on communicating with multiple children [migrated]

This is a followup to the previous question: I have a parent.py: from sys import argv from random import randrange from subprocess import Popen, PIPE lines = int(argv[1]) procs = int(argv[2]) cmd = ...
1
vote
1answer
38 views

Deadlock on read/wait [on hold]

My process deadlocks. master looks like this: p=Popen(cmd, stdin=PIPE, stdout=PIPE) for ....: # a few million p.stdin.write(...) p.stdin.close() out = p.stdout.read() p.stdout.close() exitcode = ...
10
votes
2answers
261 views

Resource usage using pipe and here string

We can get the same result using the following two in bash, echo 'foo' | cat and cat <<< 'foo' My question is what are the difference between these two as far as the resources used are ...
1
vote
1answer
19 views

CD with redirect to logger does not work

On Linux, the following cd works fine so cds into tmp: / # cd /tmp tmp # But this does not work (stays at root, nothing appears in /var/log/messages). Why not? / # cd /tmp 2>&1 | ...
1
vote
0answers
12 views

Pipe a .BIN file into XModem transfer

I need to send a .bin file to a modem via XModem transfer for firmware upgrading. If the modem is connected to a local computer, the command would be the following: sz -X -k -b -vvv - ...
0
votes
1answer
39 views

Bash : rewriting a file which is read in same line

I'm working on a bash script for partially automating router connection in command line. I'm a newbie in Bash. This is part where I have a problem: #!/bin/bash STRING2="ESSID" MYPWD=$(pwd) sudo ...
5
votes
2answers
164 views

How to send all output to `logger` in POSIX shell?

I'd like to log standard output and standard error separately in .xprofile using logger. In Bash I think that would look something like this: exec 1> >(logger --priority user.notice --tag ...
1
vote
2answers
35 views

Piping contents of multiple files between programs while keeping contents separate

I would like to read in a number of files and pipe their output to subsequent programs while still maintaining them as individual pipelines of data. program1 *.txt | program2 | program3 folder I ...
0
votes
1answer
34 views

ssh over unix pipe or pty device [closed]

Ok, I don't even know how to put this into words. I have a /dev/myDevice which automatically connects to some ssh server when opened. How do I connect to it with ssh? Is this even sane? If it's insane ...
3
votes
1answer
54 views

Joined pipelines

Considering a routine such as this one: alpha() { echo a b c |tr ' ' '\n'; } which outputs a stream, I would like to take the output stream, transform it, and paste it with the original output ...
3
votes
1answer
55 views

Possible to pipe command using su via ssh

I'm trying to write a python script to remotely update the login passwords for a set of account I administer - I can already successfully use python to pipe remote commands via the stdin of an ssh ...
0
votes
3answers
26 views

How to delete files from a directory based on the contents of a gzipped tar file?

Given that I: have a directory that contains over 1000 files have a gzip'ed tar file that contains a subset of those files (x.tgz) What is the single command line (if it is possible) that will ...
1
vote
2answers
91 views

How to while read line with a pipe

I am currently trying read a csv file with BASH. The 10th [$f10] value of the csv file must be greater then 0 for a given machine class and machine ID [m_class] and [m_id] (these are user defined) . ...
0
votes
1answer
32 views

netstat pipe count host

Unix pipe problem: how to process multiline input to output the line and insert some piped processes. echo "111 22222222" | awk '{print $1 " " $2 " " piped_processes_using_2nd_argument}' A bit of ...
5
votes
3answers
207 views

How to forward between processes with named pipes?

The /tmp/in, /tmp/out and /tmp/err are named pipes, already created and opened by some process (for reading, writing and writing, respectively). I would like to create a new process that pipes its ...
1
vote
4answers
157 views

Grep for a string in file without using pipe

I want to grep for a word in a file in the last n lines without using the pipe. grep <string> filename enables to search the filename for a string. But, I want to search for a string in the ...
2
votes
4answers
114 views

How to influence a bash while loop with a timed global variable?

I have a while loop in a bash script which should do something different at the beginning and at every 5 second interval. Any previous loop is allowed to complete. The 5s interval is indicated by the ...
1
vote
4answers
73 views

optimize command with or and pipe to parse the output of ifconfig

I have this command line, but it's doubling the grep and awk ifconfig eth1 2> /dev/null | grep "inet " | awk '{gsub("addr:","",$2); print $2 }' || ifconfig eth0 2> /dev/null | grep "inet " | ...
5
votes
1answer
156 views

Logging bash output to a file

I'm trying to build vlc which is rather complicated and dependent on having the right packages installed, and keeps choking on errors. To trace all my steps I wish to output what I'm doing to a ...
0
votes
2answers
22 views

Saving a piped value went wrong

I installed jq to handle some JSON with bash. But somehow piping the JSON string to jq in combination with saving it's output to another variable went wrong. TEST='{"foo": "bar"}' PB_SIG=$TEST | jq ...
0
votes
2answers
55 views

viewing printf after pipe (or subshell?)

Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it. The following script is meant to pipe mount.cifs commands to a while loop that enters ...
2
votes
2answers
72 views

Difference of using () and $() to execute a series of commands

I am currently trying to make a script that creates bytes that will be piped as input to netcat. Here is the idea of the script: (perl -e "print \"$BYTES\x00\"; cat file; perl -e "print \"More ...
1
vote
3answers
68 views

How to write a script that can take input from stdout

I want to be able to write a script that can take stdout as an argument, if anything is piped into it (ultimately, I would like it to be polymorphic) - The trouble is, I have searched and searched ...
6
votes
1answer
41 views

zsh I/O redirection: redirecting and then piping; what is going on?

Can somebody explain what is going on in this command: echo foo >&2 | grep foo Zsh (5.0.2) prints foo twice. One seemingly to stdout and one to stderr, since running these commands: { echo ...
0
votes
2answers
36 views

Where does pipe send its output?

I am new to using pipes and am still trying to figure out the logic of how they work. Based on reading several sources online, my understanding is that pipe in e.g., command1 | command2 sends the ...
2
votes
1answer
109 views

Piping multiple lines within bash script

I have some complicated logs that I try to parse. What I want is to find a string H, get column 5 from the line that matches, and then take all other lines where column 5 matches the line with the ...
1
vote
1answer
21 views

Pipe stdout to obexftp bluetooth transfer?

Here I have command to transfer inputFile.tar to another bluetooth device (10:68:3F:57:7D:B6). obexftp -b 10:68:3F:57:7D:B6 -p inputFile.tar However, is it possible to use stdout as input for ...
1
vote
1answer
51 views

Unzip the archive with more than one entry

I'm trying to decompress ~8GB .zip file piped from curl command. Everything I have tried is being interrupted at <1GB and returns a message: ... has more than one entry--rest ignored I've ...
2
votes
3answers
80 views

How to pipe output from cat to cut

I want to cat /proc/uptime into cut -f1 in a Bash script. I've tried; cat /proc/uptime | cut -f1 cat /proc/uptime > cut -f1 cut -f1 < cat /proc/uptime Do I need to use echo or something ...
1
vote
0answers
11 views

Pipe gzip output to Bluetooth transfer?

How do I pipe gzip output to Bluetooth transfer? I am able to send send file over Bluetooth using this command: bluetooth-sendto --device=12:23:35:96:45:45 file.tar However, piping gzip didn't ...
4
votes
3answers
41 views

Timing of ps piped to grep

So, this isn't a problem as such, just something I'm curious about. I'm using Linux Mint MATE which is branched off Debian. If I do: ps afx | grep abcdefg I get: 16599 pts/3 S+ 0:00 | ...
5
votes
3answers
365 views

Why does this one-liner fail to produce output? [duplicate]

The following produces nothing in bash: while true ; do upower -d ; sleep 1 ; done | grep percentage | uniq I've discovered that it doesn't matter what the last- or even the second to last- program ...
0
votes
1answer
49 views

How to use output from openssl encryption routines in a pipe?

openssl manual claims that openssl enc uses standard output by default. But something is not right with the standard output when decrypting a file. Piping the output to any application such as grep, ...
1
vote
1answer
66 views

piping commands after a piped xargs

HP-UX ***** B.11.23 U ia64 **** unlimited-user license find . -type d -name *log*|xargs ls -la gives me the directory name(the ones which contain log in the directory name) followed by all files ...
5
votes
8answers
702 views

How do I delete the first n lines and last line of a file using shell commands?

I have a file named Element_query containing the result of a query : SQL> select count (*) from element; [Output of the query which I want to keep in my file] SQL> spool off; I want to ...
2
votes
2answers
40 views

One-liner to sort and uniq two outputs

I'm currently doing this to sort and uniq the output of two different commands: tshark -r sample.pcap -T fields -e eth.src -e ip.src > hello tshark -r sample.pcap -T fields -e eth.dst -e ip.dst ...
2
votes
1answer
51 views

Piping a file that's being written and discarding the contents?

A software writes its logs on a file ("tonsOf.log"). Those logs are mostly useless and I process them later on with some pattern matching (line by line). So, for say 1 GB of logs, I end up with 40KB ...
2
votes
2answers
28 views

How do I close a FIFO pipe?

This script: #!/bin/bash tmppipe=/tmp/temppipe mkfifo $tmppipe echo "test" > $tmppipe cat $tmppipe exit Does not terminate. I assume that the cat command is waiting for an EOF from the pipe; how ...
4
votes
4answers
398 views

How can I get the size of stdin?

I'm about to compress a large directory and I want to know how large, exactly, the resulting file will be. I've tried using du: $ tar -cv dir | du -h - du: cannot access '-': No such file or ...
2
votes
1answer
43 views

Stateful uniq functionality

I've a program producing large amount of redundant information. I'd like to store only unique lines produced on stdout, but I can't do it in multiple steps, like: ./prog > out cat out | sort | ...
0
votes
3answers
81 views

Throw away standard output and error

I have redircted my ouput using /dev/null in bash script but it is still throwing an error. Code is following ps -p $proc | fgrep $proc> /dev/null if [ $? -ne '0' ] ; then ...... fi below is ...
3
votes
1answer
77 views

BASH: Fifo troubles - seems selective about input

So I am having a problem with a BASH service in Debian 7 that I've been working on for quite a while and that randomly started having trouble with its fifo, or so it seems. It is based on kind of your ...
2
votes
4answers
103 views

Extract two values from the output of a command

I'm using the following command in a script to get synthetic wifi info: echo "$( iw dev wlp1s0 link | grep '^\s*SSID:\s' | sed -r 's/^\s*SSID:\s//' ) $( iw dev wlp1s0 link | grep ...
3
votes
2answers
94 views

How to use a bash function like a regular command in a pipe chain?

I'm performing several commands on large files from within a bash script. In order to monitor the progress I use the pv command. An example command could look like this cat $IN_FILE | pv -w 20 -s ...
1
vote
2answers
38 views

How to preprocess CUPS' `lp` with a script for a specific printer?

(How) Is it possible to preprocess lp automatically with a script? Piping inbetween (fileToPrint | script.sh | lp -d myPrinter) is no option for me, because I have a lot of source code that does lp ...
2
votes
3answers
94 views

Is it possible to create dynamic content on file read operation?

Is it possible to generate file content based on file name? I need a lot of similar .conf files with content depending on file name only. Can I create some "dynamic" file and generate a bunch of ...
3
votes
2answers
69 views

When does cat finish reading from a pipe?

Given the following code, why does cat only print the contents of the pipe after I've typed \n or CTRL+D? What are the conditions for cat to actually print what it read? #include <stdio.h> ...
11
votes
4answers
483 views

Why isn't apt-cache policy output piped?

Cannot get why $ apt-cache policy foo N: Unable to locate package foo but $ apt-cache policy foo 2>&1 | grep . is empty. Where in the latter call am I doing the wrong assumption? The ...
1
vote
2answers
73 views

Pipe to my own script

I've recently noticed this message from grep "grep: warning: GREP_OPTIONS is deprecated; please use an alias or script" I receive this warning because --color=always is defined in my .bashrc file. ...