Skip to content

Tag: pipe

How to make pipe run sequentially

Specs Don’t think this should make a difference but I’ll include it anyway GNU bash, version 3.2.51 Premise So say i have a pipe with multiple parts, how can I prevent part of the pipe running before the previous part is finished. Example In the below examples I will try to display the issue Outpu…

How to grep a string in a program?

Description: The str_buf_to_grep is given in any way, which might be the content of a text file, and might be very long and complex, even contains special characters, such as |, “, etc. I want to use the grep command to find matched lines, and the patterns might be very complex. How should I implement i…

C: Trying to implement unnamed pipes

I’m trying to make a program that simlutates the terminal’s nameless pipes. For example, if I want to run the command: ls –l | grep ‘10’ would be: ./pipes ls -l – grep ’10’ (I use – instead of |). However, my program doesn’t work because execvp fails (bad adress). Thi…

Interpreting STRACE output – pipes and forks

I have the following code written in C, taken from https://beej.us/guide/bgipc/html/multi/pipes.html: When compiling and running this code in the terminal using strace I get the following output: Can anybody explain, line by line, what is going on in the strace output? I’ve attempted to research how to …

How to make rsync read SRC from STDIN?

I want to dump my MySQL database and make daily backups with rsync. First approach I came up with is something like mysqldump -ufoo -pbar baz > /var/tmp/baz.sql && rsync /var/tmp/baz.sql /backup/ && rm /var/tmp/baz.sql. Then I started to wonder if it is possible not to use the temporary fil…

Why doesn’t “sort file1 > file1” work?

When I am trying to sort a file and save the sorted output in itself, like this the contents of the file1 is getting erased altogether, whereas when i am trying to do the same with ‘tee’ command like this it works fine [ed: “works fine” only for small files with lucky timing, will caus…