Skip to main content

All Questions

Tagged with
1 vote
2 answers
454 views

In Bash, how can I compute and capture the result from an intermediate node in a pipeline?

In Bash, how can I compute and capture the result from an intermediate node in a pipeline? For example, given a list of integers and a command or function maximum, using a single Bash pipeline, how ...
Derek Mahar's user avatar
2 votes
3 answers
1k views

A universal `while read something` to `parallel` conversion/replacement

I have a ton of scripts which do this: command | while read something; do a long list of commands done Has anyone ever thought of how to run all the commands fed through the pipe ...
Artem S. Tashkinov's user avatar
1 vote
1 answer
477 views

bruteforcing keepassxc with bash

I have forgotten part of my password to Keepassxc database (.kdbx with keyfile). The password consists of 20 symbols, 17 of which are known. I have generated the list of all possible combinations ...
howaba3465's user avatar
3 votes
3 answers
4k views

Multiple commands and subshell execution after pipeline

Ok, I know that in Bash (by default, without 'lastpipe' bash option enabled) every variable assigned after a pipeline is, indeed, executed in a subshell and the variable itself dies after subshell ...
JohnC's user avatar
  • 41
1 vote
2 answers
1k views

How to pipe git log to curl command

My goal is to perform a curl with the output of a command as curl payload, separately they work, but I have not been able to merge both things into one. This is my first command, it prints the ...
Imnl's user avatar
  • 141
0 votes
0 answers
305 views

How to portably test for a SIGPIPE failure

In a bash script, I have a pipeline of this form /bin/find ... | grep --quiet --max-count=1 . Basically, I am just testing, yes/no, whether /bin/find found anything. Therefore, if /bin/find fails ...
kjo's user avatar
  • 16.2k
0 votes
1 answer
53 views

Find files and specify some to come first in playlist, and the rest in random order?

The following code creates a list of the files in the directory and then shuffles them in a random order then spits out the file in a text document called list.txt find *.EXT | sed 's:\ :\\\ :g' | ...
Anonymous's user avatar
  • 533
5 votes
1 answer
13k views

Why isn't it possible to read from `stdin` with `read` when piping a script to bash?

I'm not looking for work-arounds or solutions for the issue. I'm fine with it not working like that in bash. I just don't understand why it doesn't work. I'm looking for an in-depth answer why the ...
finefoot's user avatar
  • 3,504
-2 votes
2 answers
9k views

Calling sh with script on stdin and passing command line arguments

This works of course. I can run ./test1.sh cats and the argument cats is passed correctly to ls. $ cat test1.sh #!/bin/sh ls -l $1 Can you tell me how do I make this second example — the same content ...
Jack Brown's user avatar
7 votes
1 answer
4k views

How to exit early on pipe close?

I use golang for writing programs that are too complex to express as bash functions. The programs read stdin line by line and write modified output to stdout. The problem with this iterating over all ...
Kshitiz Sharma's user avatar
1 vote
2 answers
2k views

How to integrate multiple Python/Perl scripts to be executed in one bash script?

I have the following Perl scripts (though this applies to Python and other scripting languages): script1.pl, script2.pl, script3.pl The way these scripts where written, users execute them with input ...
ShanZhengYang's user avatar
2 votes
2 answers
3k views

viewing printf after pipe (or subshell?)

Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it. The following script is meant to pipe mount.cifs commands to a while loop that enters ...
Rob F's user avatar
  • 297
1 vote
2 answers
943 views

Pipe to my own script

I've recently noticed this message from grep "grep: warning: GREP_OPTIONS is deprecated; please use an alias or script" I receive this warning because --color=always is defined in my .bashrc file. ...
Caezec's user avatar
  • 13
1 vote
3 answers
203 views

Automating pipes?

I find myself using basically the same line over and over again: cat file | command1 | command2 | command3 > file Is there a way I can put all these pipes into one script, so I can just run ...
Lucas Phillips's user avatar
13 votes
2 answers
7k views

Piping for loop output prevents local variable modification

I'm trying to write a simple bash function that takes, as its arguments, a number of files and/or directories. It should: Fully qualify the filenames. Sort them. Remove duplicates. Print all that ...
tjm's user avatar
  • 233