Chains the standard streams of a series of commands

learn more… | top users | synonyms

1
vote
1answer
113 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
72 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
29 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
58 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
44 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
102 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
38 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
77 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
57 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
70 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
658 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
58 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
65 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 ...
0
votes
2answers
50 views

Are commands in a pipeline run simultaneously? [duplicate]

In a pipeline such as command1 | command2, are the commands run simultaneously (i.e. have the same lifetime), or command2 starts to run at the time command1 exits, or something else? My question ...
4
votes
1answer
127 views

uniq and bash for loop not writing to stdout before stdin closing (for one-line website visitor notification system)

I'm trying to trigger a beep on the PC speaker for every unique visitor of a website. After some brainstorming, it seemed to be possible with one line: for e in `ssh me@mymachine "tail -n 1 -f ...
2
votes
1answer
79 views

How to tell xargs which argument to choose ? [duplicate]

When xargs redirects the first commands output into the second command's argument and there is no choice about which argument for which element of the output, then there is only one way, for instance: ...
16
votes
4answers
641 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
137 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
60 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
35 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
65 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 ...
4
votes
1answer
64 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
861 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
87 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
69 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
430 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
81 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 ...
1
vote
1answer
34 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
50 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
96 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
68 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
930 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
85 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
90 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
76 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
258 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
75 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 ...
10
votes
4answers
831 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
50 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
97 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
101 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
319 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?
4
votes
1answer
181 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
665 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
64 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
1k 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
50 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
383 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
154 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 ...