Chains the standard streams of a series of commands

learn more… | top users | synonyms

1
vote
4answers
52 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
102 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
46 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
66 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 ...
0
votes
0answers
16 views

How can I get less to follow foreman? [closed]

I'm running a rails app with foreman: $foreman start -c web=1,all_worker=1 all is great and I get output to the console. Now, I want to pipe that output through less so that I can play around with ...
1
vote
3answers
66 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 ...
5
votes
1answer
31 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
33 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
75 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
13 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
42 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
51 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
9 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
28 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
358 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
39 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
58 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
469 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
35 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
48 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 ...
1
vote
2answers
17 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
374 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
38 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
56 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
67 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
91 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
82 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
32 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
82 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
56 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
472 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
66 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. ...
2
votes
1answer
101 views

pipe mplayer output to other tool

I'm trying to play an online live stream via mplayer and pipe the audio from that stream to another tool. Playing the stream works fine: mplayer http://user:pass@192.168.0.1:8080/stream.flv But ...
6
votes
3answers
115 views

How to use sed to manipulate continuously streaming output?

I am putting together a presentation for a non-technical audience. I have a program running in bash that outputs a continuous stream of values, a few of which are important. I would like to highlight ...
3
votes
1answer
107 views

Command for killing specific PID provided by previous command

Sometimes I need to kill a process (the reasons why are not important). And I know I can find that process with the following command: lsof -i :8080, being my candidate the last process in the output ...
1
vote
1answer
48 views

How to create dynamic process substitution based on the input (multiple FIFOs)?

I'm trying to create multiple process substitutions based on the output from the other command, however I'm not sure how I can achieve that. As sample scenario, I've given list of files: touch a.txt ...
1
vote
1answer
103 views

Formatting grep output with awk. Simple case and background case

I'm struggling with this problem. I have this line: mplayer *.* 2>/dev/null | grep Playing which just launchs mplayer and only the line matching Playing filename is printed on screen. This works ...
0
votes
1answer
53 views

Feeding audio from microphone live into python

Well, so I was reading about this raspberry pi tutorial that makes you play audio files from raspberry pi and stream them into a FM signal and something got me curious. You can stream .wav files, ...
-1
votes
1answer
27 views

Does those two constructions do the same thing: proces <input.txt vs cat input.txt | process in Linux

Does those two constructions do the same thing: proces <input.txt vs cat input.txt | process in Linux?
1
vote
1answer
50 views

In-place substitution for paste command [duplicate]

When I run the following code echo '1' > file.txt echo '2' | paste file.txt - > file.txt I would expect the content of file.txt be 1 2, because the paste command as it name suggests should ...
1
vote
0answers
31 views

Correct/Efficient/Reliable way to import log file entries to a MySQL database?

I'd like to be able to query our server access log files to identify abuse patterns. Log files really aren't very queryable, and it would be fairly easy to do what I wanted if each hit was a row in a ...
6
votes
1answer
87 views

Does tee slow down pipelines?

I am wondering whether tee slows down pipelines. Writing data to disk is slower than piping it along, after all. Does tee wait with sending data through to the next pipe until it has been written to ...
0
votes
2answers
36 views

Separate execution status of piped commands

In a command where we have lot of pipes redirecting their outputs further, is there any way to get to know the value of echo $? till half of it's execution or till certain number of pipes, as opposed ...
3
votes
0answers
61 views

Scripted write-then-read from Unix domain socket using socat

I have a simple server listening on a Unix domain socket (on a CentOS box in case that's important). When I send the command "DATE" to the socket it writes back a welcome message and then "APRIL 15 ...
2
votes
3answers
52 views

Extracting archive by piping contents of archive into the tar command

I am creating a self-extracting archive and I have got the basic thing going. However I want to set the command that extracts the archive contents tail -n+$ARCHIVE_START_LINE $0 into a variable. I ...
2
votes
1answer
58 views

Syntax When Combining dd and pv

I am a linux newbie; so, sorry if this is obvious to you... sudo dd if=/dev/sda bs=64k | pv --size 1.5t | dd of=/dev/sdb Does the block size for dd go on the left side of this after the input as ...
14
votes
9answers
599 views

Filter or pipe certain sections of a file

I have an input file with some sections the are demarcated with start and end tags, for example: line A line B @@inline-code-start line X line Y line Z @@inline-code-end line C line D I want to ...
0
votes
2answers
56 views

How is pipe involved in ssh?

My internet connection was lost When I ssh to a remote machine over the internet. It says $ Write failed: Broken pipe How is pipe involved in ssh? Does ssh implement communication between the two ...
1
vote
2answers
63 views

Merge lines in file together from regex to “lineify” multiline log log files

Stadard unix command line tools (grep, cut, sed etc.) all work one line at a time. And nearly always, this is great. However I am trying to parse some postgresql slow query logs. Each entry has some ...