Tagged Questions

Chains the standard streams of a series of commands

learn more… | top users | synonyms

0
votes
2answers
39 views

How does Bash pipe large amounts of data?

Let's say you want to cat the contents of a really big file, but want to view it a few bits at a time. Let's say one were to do the following: $ cat /dev/sda1 | less As a programmer of languages ...
1
vote
3answers
29 views

Command that passes its input through to output AND performs command?

I'm trying to use the quote program to make a little shell script that'll keep updating the stock prices every second. quote has to access the Internet and therefore has a small delay when it runs. I ...
1
vote
2answers
39 views

Combination of echo, pipe and cat

I have a file name called temp.csv in my script one of the intermediate step is echo "some info" > final.csv | cat temp.csv >> final.csv at times the file final.csv is created without ...
1
vote
1answer
31 views

Using find -exec and having trouble with redirecting standard error

I have an individual.sh script that pipes standard error to a grep command, like this: FOUND=$(tesseract "$i" out -psm 0 |& grep -ci 'Orientation in degrees: [^0]') If I run the script like ...
2
votes
1answer
30 views

Confused about piping commands from find to commandX?

I have a script, run.sh, that looks like this: #!/bin/bash FILES=$(find corpus/ -type f) for i in $FILES do ./individual.sh $i done It runs without problem. I want to do away with the run ...
1
vote
1answer
43 views

Pipes & redirection binding precedence with disjuncts, conjuncts etc?

I know of the relative binding precedence of operators ‘;’, ‘&’, ‘&&’, or ‘||’ http://www.gnu.org/software/bash/manual/bashref.html#Lists but when pipes come into the picture along with ...
1
vote
0answers
30 views

In adb logcat | grep, how to get the entire original line? [closed]

I am using grep on the Android Logcat to only watch the lines related to my application. My command line is like: adb logcat | grep 'MyAppName' But the results I get is not the original logcat ...
3
votes
1answer
30 views

How to find the file corresponding to a pipe opened by a process? [duplicate]

I created this script, which listens for characters received on a hardcoded pipe, and tries to eval those characters. I call my script loop_executor.sh This is all it contains: !/bin/bash while : do ...
1
vote
1answer
28 views

Redirect output to stdout and pipe to a binary

I have a nice PS1 line in my .bash_profile, and I want to copy it to another machine. So I want to view it AND copy it to my clipboard. I can't figure out how to string the commands to do this ...
-1
votes
0answers
13 views

How does the parent select which forked child process to communicate with? [migrated]

I created several child processes from one parent, and I also created bidirectional pipes between each process and the parent. Now the problem is how can I go back and forth between the child ...
2
votes
1answer
42 views

Advantages of using named pipes and sockets rather than temporary files

I have two cooperating programs. One program just writes its output to a file and the other one then reads from the file and spits the data out for the front end to work with. I have been reading ...
3
votes
2answers
94 views

How can a bash script write its standard output from within a pipeline? [duplicate]

I have a bash script that calls a function. The function, amongst other things, executes a pipeline that sinks its output. To simplify it, here is a contrived example: #!/bin/bash func() { ls "$@" ...
1
vote
2answers
40 views

Append a file, output to screen and redirect from stderr all at once, without tee

I'm running a time dd command in a shell script, and I'd like to output the results to a file, and print it out on the screen. The line that I'm currently running is: (time dd of=$dest_filepath ...
5
votes
3answers
185 views

Use bash's read builtin without a while loop

I'm used to bash's builtin read function in while loops, e.g.: echo "0 1 1 1 1 2 2 3" |\ while read A B; do echo $A + $B | bc; done I've been working on some make project, and ...
1
vote
1answer
48 views

Understanding grep and pipes in linux

I came across this post which explains my problem. Suppose there is a file called file.txt which contains "foo World". The answer posted by Tyler explains a lot however I am confused as to how cat ...
0
votes
2answers
95 views

How to redirect stdout & stdin to telnet? [closed]

I am working on embedded product running Linux. The device uses /dev/ttyO0 as console. On boot is automatically start a program with which uses input from /dev/ttyO0 (serial), and gives some ...
4
votes
3answers
58 views

Time required to do pipe output to head/tail [duplicate]

There are lots of txt files in a directory. If I do time wc -l *.txt | head it takes real 0m0.032s user 0m0.020s sys 0m0.008s If I do time wc -l *.txt | tail it takes real 0m0.156s ...
0
votes
4answers
65 views

grep for files and open the resultant matches

I'm trying to open all files based on some return values from grep in the command line. I know that I can use the -l option to only return filenames, but I would like to combine this somehow with ...
0
votes
1answer
73 views

Very basic H/W question using pipe and grep

I have two text files, F1a.txt and F1b.txt, with essentially the same data: the driver's surname and their nationality. For example: Hamilton GBR Alonso SPA I have concatenated these ...
-1
votes
1answer
42 views

Redirect a directory as input to a script and output to a file

I want to use a directory name as a parameter for a pre-made script. Then the output goes into a newly made file in the home directory. It involves pipe/redirection. How do I do that? read dir $dir ...
0
votes
2answers
32 views

Using a file as an input to a script

Say I want to use the name of a file as input, and process it with a pre-made script in a certain directory. How do I do it? fileName < /folder1/scriptName is this the right format?
0
votes
1answer
23 views

Using $BASHPID in grep statement

I'm trying to exclude the PID of the subshell from the results returned by pgrep. Note that the name of the file is the same as the name passed to pgrep. Why does setting a variable equal to BASHPID ...
2
votes
2answers
66 views

redirect output of tee and grep for multiple logfiles

Redirecting output from a script STDOUT + STDERR toLogfile 1 and a grep to Logfile 2 ./run_test.sh 2>&1 | tee -a /var/log/log1.log | (grep 'START|END') > /var/log/myscripts.log How can I ...
4
votes
2answers
101 views

How to capture ordered STDOUT/STDERR and add timestamp/prefixes?

I have explored almost all available similar questions, to no avail. Let me describe the problem in detail: I run some unattended scripts and these can produce standard output and standard error ...
3
votes
1answer
48 views

Make program in a pipe to think it has tty

Test environment: $ mkdir testdir $ cd testdir $ echo | tee "file name" Now, ls will print file?name (under Ubuntu GNU bash, at least), while ls | cat will print file and name in separate lines. ...
0
votes
0answers
32 views

Create tar file which consists of directories from another tar file

I have tar file with three directories, dir1, dir2 and dir3. Is there a way to extract dir2 and dir3 directories to create new tar file on the fly, without extracting the directories in temporary ...
1
vote
2answers
30 views

If I use one of the exec family functions to open a child process, will pipes to parent be applied to the child?

Say I open a parent process with a master process that assigns the stdout to a file for logging. Then say I use the parent process to open a child with execvp (or any other of the exec family of ...
1
vote
2answers
67 views

Concatenate file contents AND names

I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
1
vote
1answer
55 views

Is the data transiting through a pipe confidential?

I read the following question (Shell Script mktemp, what's the best method to create temporary named pipe?) but I'm wondering whether it is preferable to use a temporary named pipe to transfer ...
4
votes
3answers
147 views

Get PID of any command in backgrounded piped sequence of commands

If, in bash, I execute: cmd1 | cmd2 | ... | cmdi | ... | cmdn & where the cmd{1..n} may not be distinct, how do I get the PID of cmdi? Alternatively, how can I signal the cmdi process? (For ...
5
votes
2answers
237 views

Why does process substitution result in a file called /dev/fd/63 which is a pipe?

I am trying to understand named pipes in the context of this particular example. I type <(ls -l) in my terminal and get the output as, bash: /dev/fd/63: Permission denied. If I type cat <(ls ...
2
votes
2answers
57 views

Should I use piping or redirection for input to 'sort'

I want to do awk -F "," '{print $1 }' inputfile1.txt | sort -u > distinctOutput.txt Is this good performance-wise ? Or should I redirect / use a temp file since I think it is better to make sort ...
1
vote
1answer
76 views

What is happening while executing this command cd / | vi?

When I execute the command cd / | vi, it goes to the vi editor. When I type any command it does not display the command but it gets executed and the command that is executed is not shown in the ...
-2
votes
1answer
54 views

Delete empty directories without find

I want to delete empty directories without using find command like the following: Instead of find . -empty -type d -delete use if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi ...
26
votes
4answers
2k views

Why does “tail -f … | tail” fail to produce any output?

Why does the following command not produce any output? $ tail -f /etc/passwd | tail After reading about buffering, I tried the following to no avail: $ tail -f /etc/passwd | stdbuf -oL tail Note ...
2
votes
0answers
22 views

Close All Piped Commands if one close

I'm running at least 3 commands (with progs) using pipes. For example program1 bla bla | program2 blabla | program3 bla bla Is possible to close all programX PIDS automatically if at least one ...
1
vote
0answers
33 views

Verbose output in logfile and simple output on screen?

Let's say I have the following script: script.sh and i want the verbose output in a logfile and simple output on screen. Logfile should contain the csh -v script.sh output, and on the screen should ...
2
votes
1answer
51 views

How can I pipe the output of a program or function into a variable?

How can I pipe the output of a program or function into a variable? For example lets say I have this script: function foobarize () { sed \ -e "s|${foo}|${bar}|g" \ $1 } echo foo | ...
5
votes
2answers
129 views

How do I preserve coloured output when piping to `less -R`?

$ ffmpeg -v debug ... Coloured output. $ ffmpeg -v debug ... |& less -R Dull output. How do I make the output coloured while piping it to something?
3
votes
2answers
55 views

Problem with read variable from AWK

I'm trying to get memory info by this command: #!/bin/bash set -x cat /proc/meminfo | grep "MemFree" | tail -n 1 | awk '{ print $2 $4 }' | read numA numB echo $numA I'm getting this + awk '{ print ...
2
votes
1answer
56 views

Why doesn't PIPESTATUS work on pipelines within a command substitution

Proof below: Bash 4 Prompt> $(echo hello|sed 's/h/m/'|xargs -I{} ls {} 2>/dev/null|sed 's/ /_/') Prompt> for i in ${PIPESTATUS[@]}; do echo $i;done Output> 0 Prompt> echo hello|sed ...
3
votes
4answers
184 views

Redirect and pipe output

rpm -qa > file | wc -l returns 0. What am I doing wrong? I think it is clear what my goal is, but it isn't working. Is this a job for xargs or tee?
1
vote
3answers
65 views

How can I pipe data over network or serial to the display of another linux machine?

I have a second monitor that I'd like to use for a text-based debugging log and/or console. I don't want to have it as part of my GUI / "desktop" / main system. I have this display connected to an ...
1
vote
1answer
70 views

Why doesn't this piped script work?

#!/bin/bash rm out mkfifo out nc -l 8080 < out | while read line do echo hello > out echo $line done If I browse to the IP of the machine this script is running on (using port ...
4
votes
1answer
72 views

unexpected output with grep

I am using pyrit. For those who dont know, pyrit allows among other things to check if a wpa handshake key is valid: pyrit -r file0.cap analyze when a file does not contain a valid key, here is ...
1
vote
1answer
156 views

Why are these values not appending correctly when appended to the pipeline? [duplicate]

I have a bash script (seen here) that I'm using to sort a list of files in subdirectories by filename. This script appends sorted files in hooks/pre-relevant/, then files named hooks/pre-relevant, ...
2
votes
1answer
49 views

Is there a system call to bind a file descriptor directly into another?

A read() & write() loop would probably be as good as what I'm looking for, but nevertheless is anything like that around or is it impossible because of an obstacle I didn't envisage ? I'm curious
6
votes
2answers
324 views

check md5sum from pipe

I am confused how md5sum --check is supposed to work: $ man md5sum -c, --check read MD5 sums from the FILEs and check them I have a file, I can pipe it to md5sum: $ cat file | md5sum ...
1
vote
1answer
24 views

What standard shell command can evaluate escaped Unicode in a stream?

I'm looking for a pipeable command that will convert substrings in the form of ‘\unnnn’ to the actual characters. For example: $ echo 'co\u00ebfficient' | what_command coëfficient
8
votes
1answer
735 views

How pipes work in Linux

I've been reading up about how pipes are implemented in the Linux kernel and wanted to validate my understanding. If I'm incorrect, the answer with the correct explanation will be selected. Linux ...