Chains the standard streams of a series of commands

learn more… | top users | synonyms

0
votes
1answer
22 views

Having extra parameters in piping or redirection

I have two programs and I want to pipe them into each other but they take extra parameters: prog1 <inputfile> <outputfile> min max prog2 <inputfile> <outputfile> min max ...
0
votes
1answer
15 views

cat SQL files and pass to import schema

I am trying to import a series of .SQL files which map one file per DB object into mysql without calling mysql 50 times, something like: mysql -u root < cat schema/db1/*.sql This isn't working ...
25
votes
5answers
2k views

Why pipe to cat only to redirect? [duplicate]

I occasionally see things like: cat file | wc | cat > file2 Why do this? When will the results (or performance) differ (favourably) from simply: cat file | wc > file2
7
votes
4answers
109 views

How can I filter the contents of a tar file, producing another tar file in the pipe?

Consider a single tar file from an external system which contains some directories with various attributes which I want to retain such as permissions, mtimes, etc. How can I easily take a subset of ...
3
votes
1answer
126 views

How do I append an item to an array in a pipeline? [duplicate]

This script should simply add a value to an array through a loop and then show all items of an array. #!/bin/bash data_file="$1" down=() counter=0 cat $data_file | while read line; do \ ...
6
votes
1answer
86 views

Extra output on input redirection

I have a folder with three files: $ ls a b c If I pipe the output of ls to wc, I get the right result: $ ls | wc -l 3 However, when I specify the input to wc as the output of ls, I get extra ...
0
votes
1answer
40 views

piping a password located in a file to the ssh command [duplicate]

So I need to login as a lot of different users to a server using ssh and I'm tired of copying the password from the files, which contain the passwords for the users, each time. I can't change it to ...
0
votes
1answer
55 views

How to use pipe to assign a variable [duplicate]

I am new to bash script. Probably this is very easy but for me it's not working. How can I assign value of $x1+$x2 to bc by piping. here in my code $bc holds no value. echo -n 'value x1 : ' read x1 ...
4
votes
3answers
548 views

Behaviour of “|” pipe in linux with “>” output redirection

I am executing command ls > a.txt | sort > b.txt This command is doing the below things : executing ls sorting it creating a.txt and storing sorted output to a.txt creating b.txt , but its ...
-2
votes
2answers
47 views

Pipe Named Fifo [closed]

I am implementing a named pipe to write and read data between two processes in cpp. The first process acquires a feature point from an image in real time while the second reads this feature point. It ...
1
vote
1answer
22 views

unzip a file and pipe to “ddrescue” command

I have a zipped image file, and need use "ddrescue" command instead "dd" to do something like this: unzip -p ubuntuXXXX.img.zip | sudo dd bs=2M of=/dev/sdb But "ddrescue" needs the image file as ...
2
votes
3answers
36 views

Who forks the processes of piped commands in the shell?

Suppose this command in the shell : ls|less Now we know that ls and less are run as two different processes. We know that the shell forks and creates a child process which load the ls program using ...
0
votes
4answers
71 views

piping commands not working as expected I need explanation

I am trying to do the below touch ~/scratches/scr6.txt | cat ~/scr.txt > ~/scratches/scr6.txt | cat /dev/null > ~/scr.txt I don't know why scr6.txt is always empty, however doing the below ...
3
votes
1answer
49 views

Round-tripping text through zip, unzip fails with 'extra bytes' error on OS X [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 the following output: ...
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
49 views

Deadlock on read/wait [closed]

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 = ...
14
votes
2answers
331 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
21 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 | ...
2
votes
0answers
23 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
50 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
180 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
38 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
38 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
88 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
33 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
101 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
40 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
216 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
189 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
155 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
81 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
248 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
68 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
70 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
49 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
38 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
141 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
22 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
70 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
135 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
14 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
72 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
370 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
65 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
70 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
1k 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
45 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 ...