Skip to main content

All Questions

Tagged with
3 votes
2 answers
86 views

print_one_line_and_wait_long_time | head -n1: early exit of pipe/process substitution [duplicate]

tl;dr: How to reliably ensure that the pipe a | head -n1 terminates as soon as head terminates? Motivation: git log --grep="$MAIL_SUBJECT_LINE" --oneline --format=%H | head -n1 takes a long ...
teapot's user avatar
  • 361
0 votes
2 answers
86 views

Piping output to bash script

I'm going through the "sed & awk" book by Dougherty and Robbins. One of the examples calls for piping output to a shell script: sed -f nameState list | byState But I've found that, in ...
Mike's user avatar
  • 103
2 votes
1 answer
76 views

Is there a way to `exec` a pipeline or exit shell after launching a pipeline?

I'm writing a shell wrapper script that is supposed to act as a pager (receiving input on stdin and performing output on a tty). This wrapper prepares environment and command lines, then launches two ...
intelfx's user avatar
  • 5,659
0 votes
1 answer
60 views

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 ...
Robert Altman's user avatar
0 votes
0 answers
790 views

Understanding bash read variable substitution [duplicate]

First of all, I have little experience using Bash and I apologize for my bad English. Maybe it's obvious. I am trying to understand why Bash drop value of the variable in this oneliner. echo "...
bas1c's user avatar
  • 1
0 votes
0 answers
27 views

Bash equivalent of zsh alias at end of command (for pipes) [duplicate]

In zsh, I can set an alias at the end of a command, e.g. making G pipe through grep or L pipe through less. Can I do something similar in bash? E.g. ls G key would expand to ls | grep key or ls L ...
SRobertJames's user avatar
0 votes
2 answers
1k views

Get exit status of the first command in a pipeline *in the second command*

My question is similar to Get exit status of process that's piped to another, but I want to get the exit status of the first command in the pipe within the pipe. Here's an example: false | echo &...
MilkyDeveloper's user avatar
1 vote
4 answers
156 views

How can I use else for `ifne`?

ifne - Run command if the standard input is not empty If possible I want to run command if the standard input is empty as well; else section for ifne. $ printf "hello" | ifne echo "...
alper's user avatar
  • 507
0 votes
0 answers
78 views

Creating a script which compares the return value from an AT command

I am trying to write a shell script that can save the output of a piped process to a variable. This variable is then compared to a known string in order to discern whether or not my AT modem is ...
adamsthename's user avatar
1 vote
1 answer
961 views

Teeing each output while capturing return exit code (are any env variable) and passing it back "up the chain"

I've been struggling and reading quite a bit about this, and clearly bash is probably not the best tool for this, but since I'm already dug this deep into this hole (too much of the code is already ...
Lockszmith's user avatar
1 vote
4 answers
310 views

How to use a value from sub shell in parent shell

I'm not used to linux scripting and this is the first time I'm working on it so I'm struggling with the following problem: Code: while [ $pct -gt 80 ]; do flag=1; ls -tr | while read file; do ...
Biswadeep Sarkar's user avatar
0 votes
2 answers
466 views

Unable to match a specific regex with bash

I have a txt file with content as such: Adedunmola Okikiola Adewole 512.035 215−39 ^M Ademir Cleto de Oliveira 055.735 445−13 ^M Adilson ...
BuddhiLW's user avatar
  • 143
0 votes
2 answers
326 views

Incremental reading from pipe

Trying to figure out how to have a shell script only take fix-length blocks out of stdin. I would have thought something like this would have worked, but it does not: #!/bin/bash value=0 while [ &...
A. Que's user avatar
  • 653
1 vote
0 answers
112 views

How to extract a value from a piped output to a variable repeatedly while the output is still being written

I want to update the download status at every 5 second of file to my telegram bot. Also here I'm using bash. aria2c $url --summary-interval=5 2>&1 | tee output.log | grep -oP "(\d+(\.\d+)?(...
sauraj's user avatar
  • 21
2 votes
1 answer
558 views

File descriptor 10 when running a script (Bash/dash, etc.)

When the script runs, a file descriptor 10 appears with the contents of the executable script. For example, the script: #!/bin/sh sleep 600 When viewing the fd of a running script through processes, ...
NewLinux's user avatar
  • 157

15 30 50 per page
1
2 3 4 5
7