pipe

pipe to a different file descriptor

pipe to a different file descriptor Following up on Using while loop to ssh to multiple servers, i.e., for while IFS= read -r -u9 HOST ; do ssh "$HOST" "uname -a" ; done 9< servers.txt which reads from a different file descriptor (9), How to make it read from a pipe of a different file …

Total answers: 1

SIGPIPE and bash pipefail

SIGPIPE and bash pipefail I am trying to better understand SIGPIPE on linux. I ran this experiment: { ls -al /tmp/ ; echo "$?" 1>&2 ; } | head and it echos 141 which I understand is an exit code that is given to processes that exit with SIGPIPE Previously, I have done this a …

Total answers: 1

rsyslogd v3.x.x unexpectedly closes write connection to named pipe target

rsyslogd v3.x.x unexpectedly closes write connection to named pipe target I’ve configured rsyslog to forward certain log messages to a named pipe /tmp/logger.pipe. I then have a separate process reading from the named pipe. Relevant section from /etc/rsyslog.conf # Remote Logging (silly conditional rule needed for specific logging scenario) $template RFC5424Format,"<%PRI%>1 %timegenerated:1:10:date-rfc3339%T%timegenerated:12:19:date-rfc3339%.%timegenerated:21:26:date-rfc3339%Z %HOSTNAME% – – …

Total answers: 1

Performing character-level comparison of "strings" without explicitly creating temporary files for git diff

Performing character-level comparison of "strings" without explicitly creating temporary files for git diff Referring to this https://stackoverflow.com/a/31356602, I wrote this code: #!/bin/bash # Define the two strings to compare string1="First string with some random text." string2="Second string with some random text and some changes." # Create a temporary directory temp_dir=$(mktemp -d) # Create temporary files …

Total answers: 1

Why doesn't the given command mask other lines?

Why doesn't the given command mask other lines? Command: sudo find / -name miniedit.py -print | grep -i "miniedit" | tail -1 Output: find: ‘/proc/10031/task/10031/net’: Invalid argument find: ‘/proc/10031/net’: Invalid argument find: ‘/run/user/1000/gvfs’: Permission denied find: ‘/run/user/1000/doc’: Permission denied /usr/share/doc/mininet/examples/miniedit.py Expected output: /usr/share/doc/mininet/examples/miniedit.py What am I doing wrong? Asked By: kesarling He-Him || Source You …

Total answers: 1

find with execdir, pipe redirection evaluated too early (quote issue?)

find with execdir, pipe redirection evaluated too early (quote issue?) I use multiple GitHub accounts at work, so I need to modify the remote url to add my work account. I have figured out the recursive find -execdir, and how to get/sed/set the remote url, but I cannot combine them. I tested the find command …

Total answers: 1

Why is tee stopping in the middle when piped with nohup?

Why is tee stopping in the middle when piped with nohup? I’m running a script (in a Laravel project) that takes a few hours to complete. nohup to prevent it from exiting if my ssh session is disconnected. nohup php artisan do:thing 2>&1 | tee ~/tmp It starts off nicely, but after some time, I …

Total answers: 1

Kill process on broken pipe from within a bash script

Kill process on broken pipe from within a bash script Consider the code: printf ‘%sn’ 1 2 3 4 5 | head -n 2 which has the output: 1 2 My understanding is that when the head process breaks the pipe after reading the two first lines then the printf process catches the broken pipe …

Total answers: 1

SSH's -t option – how do I remotely execute a complex command that includes pipes and variable expansion?

SSH's -t option – how do I remotely execute a complex command that includes pipes and variable expansion? The following script is run by root and is meant to share two directories from jim’s computer to that of oumaima. #!/usr/bin/bash au=$(echo "$(head -n 1 /etc/doas.conf)"|sed ‘s/permit//;s/as//;s/root//;s/ //g’) dirs=( "/var/lib/transmission-daemon/downloads" "/home/${au}/VisualArts/films_FR" ) dst_ip="[fe80::cc08:9467:8dba:15a9%wlp4s0]" her_host="fe80::cc08:9467:8dba:15a9%wlp4s0" give_oumaima() { …

Total answers: 1

Capture output from SOX "-n stat"

Capture output from SOX "-n stat" I am trying to capture/pipe the output from the following: arecord -f S16_LE -qd 5 file && sox file -n stat output: Samples read: 8000 Length (seconds): 1.000000 Scaled by: 2147483647.0 Maximum amplitude: 0.992188 Minimum amplitude: -0.992188 Midline amplitude: 0.000000 Mean norm: 0.093221 Mean amplitude: -0.015338 RMS amplitude: 0.232947 …

Total answers: 1

zsh: check exit code of pipeline of commands

zsh: check exit code of pipeline of commands I have long pipeline of commands in zsh script: pv /dev/sda > sda.raw | sha256sum > sda.raw.sha256 | cut -c61-64 | read SHASUM how can I check inside an if statement, that all commands exited successfully? I know about ${pipestatus[@]}, but it is an array. So I …

Total answers: 1

Two-way pipe in bash?

Two-way pipe in bash? I have a binary who’s stdout is being redirected to the stdin of a python script, and I was wondering if there’s any way to send the stdout of the python script to the stdin of the binary, to get an effect something like this, (excuse my terrible ascii diagram): |->-binary …

Total answers: 1

Android Device on Linux

Android Device on Linux I have a Desktop PC running Ubuntu, I also have an Samsung galaxy Tablet. I am looking for a solution for the following needs: Connect tablet to PC. Tablet opens up as an application window. Application window outputs sound and video from the tablet. Application window takes keyboard and mouse input …

Total answers: 1

Pipe : gunzip files and concatenate

Pipe : gunzip files and concatenate I feel like this should be simple. I have a directory with >1000 gzip-ed files. I’d like to gunzip them all and concatenate. Running gzip -dk *.gz | cat > output.file produces the following error: Too many levels of symbolic links Ideas? Asked By: ThePresident || Source zcat — …

Total answers: 1

Is there a program that concatenates non-seekable streams (size not known in advance) and can separate them again?

Is there a program that concatenates non-seekable streams (size not known in advance) and can separate them again? I’m trying to concatenate multiple input files/streams into one stream (using the imaginary command stream-cat), pipe that stream into ssh and on the remote host separate it back into individual files/streams (stream-sep), like in this example, which …

Total answers: 2

How to pipe STDIO from a thread process to /dev/null?

How to pipe STDIO from a thread process to /dev/null? I am trying to run Plarium Play with wine, but have encountered an odd issue. When trying to launch it from a regular desktop entry, I get this JavaScript error: This does not happen if I launch from the terminal. If I try and launch …

Total answers: 1

Copy the n-largest files from a certain directory to the current one

Copy the n-largest files from a certain directory to the current one I am trying to copy five largest files from a certain directory to my pwd. Using cp specific/directory$(ls -S specific/directory | head -n) ./ copies the first file and then proceeds to produce cannot stat errors for the rest of the files in …

Total answers: 4