Hot answers tagged

3

Nothing surprising here, after all > POSIX says, DESCRIPTION The tee utility shall copy standard input to standard output, making a copy in zero or more files. The tee utility shall not buffer output. And also that RATIONALE The buffering requirement means that tee is not allowed to use ISO C standard fully buffered or line-buffered writes. ...


3

You want to pipe the output of both commands as a group to the final script, not the output of echo to cat. So group those commands using { ...; } or (...): { echo 'use database'; cat create_tables.sql; } | work_send_command_to_db.sh Or: ( echo 'use database'; cat create_tables.sql ) | work_send_command_to_db.sh


3

Let tee duplicate the output from ping to rev using a process substitution (assuming you are using a shell that supports these) and to the terminal: $ ping -c 3 stackexchange.com | tee >(rev >/tmp/rping) ping: Warning: stackexchange.com has multiple addresses; using 151.101.65.69 PING stackexchange.com (151.101.65.69): 56 data bytes 64 bytes from 151....


3

Using tee: ping -c 3 stackexchange.com | tee /dev/tty | rev >/tmp/rping


2

This comment is true: Each part of a pipeline is started independently of the other parts of the same pipeline. This means that $x can't be available in the middle of the pipeline if it's set in one of the other stages. This doesn't mean you cannot do anything. A pipeline may be considered the main data channel, still processes can communicate using side ...


2

You could try something like this: curl -vX POST --data-urlencode \ "payload={\"text\":\"`git log --pretty=oneline HEAD...$(git tag -l | tail -n2 | head -n1) | tr '\n' ',' | sed 's|,$||'`\"}" \ https://<your-remote>


2

The way I deal with this is to write the output to a file and then page the file. Using your example, this would be i=0; while true; i=$((i+1)); do echo $i; sleep 0.001; done >/tmp/somefile less /tmp/somefile The disadvantage is that depending on the process generating output, /tmp/somefile can grow arbitrarily large. The reason for writing/reading ...


2

Any block size greater then PIPE_BUF (5k on modern UNIX, 4k on Linux) is not granted to pass a pipe without fragementation. This means, it may be split, but there is no grant for a split. Whether you are able to read more than PIPE_BUF at all depends on the memory state of the kernel that controls when the write side is stopped by the kernel to prevent it ...


2

You don't need anything else - just type paste -sd+ | bc then hit ENTER after which you can type or paste the numbers (separated by newlines), ending your input with CTRL+D $ paste -sd+ | bc 1.23 4.56 7.89 13.68 Alternatively, use a here document $ paste -sd+ <<EOF | bc > 1.23 > 4.56 > 7.89 > EOF 13.68


2

You are seeing error messages produced by md5sum for missing files. These messages are produced on the standard error stream, and since it's only ever the standard output stream that is passed across pipes, the error messages won't be affected by the grep command at all. To redirect them away so that you don't see them at all, use md5sum -c MD5SUMS 2>/...


2

It looks like what you need is command substitution, not pipes: outputOfcommand1=$(command1) outputOfcommand2=$(command2 "$outputOfcommand1") command3 "$outputOfcommand1" "$outputOfcommand2"


1

Nevermind, found it: lxc exec memsql1 -- bash -c "the command with | pipe"


1

| is not a command. So that is not possible. But you might be able to simulate what you want by using history and abusing $PS1: PS1="$PS1"'`(date;history | tail -n1 | perl -ne "s/\|.*// and print") >> ~/pipe.log`'


1

I just found a solution: You have to "unbuffer" each command with stdbuf -oO. So it should look like that: stdbuf -o0 tail -f -n 2 /var/log/apache2/error.log | stdbuf -o0 awk '{print substr($0,83, length($0)- 166); }' | jq


1

Using an alias is generally not good practice in non-interactive shell scripts ( BashFAQ/080 ). The way you have the alias defined in your OP, only the first commands reads from the standard input, because ; terminates your standard input from going beyond your first command. One possible way is to do a command grouping using {..}, so that any re-directions ...


1

./bar < <( ./foo ) For example: cat < <(echo "hello there!") To understand how it works, consider parts of the script separately. This syntax: cat < /path/to/file will read the file /path/to/file and pipe it as stdin to cat. This syntax: <(echo "hello there!") means to execute the command and attach the stdout to a file descriptor like /...


1

I know this is a bit old but no other answer worked for me and this did: echo 'test' | netcat -N $server $port Notice the -N: shutdown the network socket after EOF on the input. Some servers require this to finish their work. Worked for me on both Windows and Linux. Note: This is a copy paste of the answer I posted for a duplicate question. I'm ...


Only top voted, non community-wiki answers of a minimum length are eligible