Hot answers tagged

5

If you want the cat process to terminate (and the Y to be printed) before the Xs, then just call close("cat") after the print "Y" | "cat". All the rest is explained in the manpage, which you better read. Why isn't Y printed first given that it's supposed to run before the other statements? The cat is not supposed to write its ...


3

Redirections and pipes in awk are similar to redirections and pipes in sh, but there is one major difference. In sh, foo >bar keeps bar open only for the duration of the foo command, and foo | bar waits for both foo and bar to terminate. In awk, a redirection or pipe remains open until it's closed explicitly, and redirecting or piping to the same file ...


2

To keep the pipe open, don't let it close. You may do this by adding cat to the left hand side in the pipe: { echo "cd /storage/self/primary/Download; mkdir bobby"; cat; } | adb shell The cat process will execute after echo, and have its standard output connected to the adb shell command, while its standard input reads from the terminal (where ...


2

Inside the shell script, do this: data=$(cat) that will use the cat command to read standard input and store the result in the $data variable. Read about the $(...) syntax here: 3.5.4 Command Substitution


1

Just use a shell loop. You can join your two grep commands into a single one, and there's no point in piping the genpwdfile if it creates a file. Try this: genpwdfile dec -in test/test.cfg -out /tmp/dec.out && grep -E 'PORT_NUM|MONITOR_PORT' /tmp/dec.out | cut -d '=' -f2 | while read -r port; do lsof -i:"$port" 2>/...


1

Bacticks are used for command substitution, you need: watch './md /dev/ttyUSB0 | xxd'


1

Not directly. It could, but it would need to identify the pipe it is connected to, then search all other pid for one connected to that one. Suppose receiver had pid 1730. It could look at /proc/self/fd/0 (or, more easily, /proc/self/fd/0) and see it shows as a symlink to pipe:[43270]. /proc/1730/fdinfo/0. Then it could discover that /proc/1729/fd/1 shows as ...


1

Read man isatty, or https://linux.die.net/man/3/isatty isatty - test whether a file descriptor refers to a terminal


1

I would go for @strugee answer but I'll use the numfmt tool which is designed for memory unit conversion and supports many options: tar -cv dir | wc -c | numfmt --to=si --to=si will display the output in SI units (e.g: 4G)


1

( your_input_pipeline & ) | less +F and { your_input_pipeline & } | less +F seem to work in Bash. It works also in Zsh and Dash except that the INT signal propagates to the enclosing shell after less exits. Does not work in Ksh. Test configuration: GNU bash 5.0.17 dash 0.5.10.2-6 (package version in Ubuntu Linux) zsh 5.8 less 551


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