Tag Info

Hot answers tagged

18

You do this: cat file | md5sum > sumfile And the next day you can do this: cat file | md5sum --check sumfile Which prints: -: OK if everything is alright.


8

For commands that do not have an option similar to --color=always, you can do, e.g. with your example: script -c "ffmpeg -v debug ..." /dev/null < /dev/null |& less -R What script does is that it runs the command in a terminal session. EDIT: Instead of a command string, if you want to be able to provide an array, then the following zsh wrapper ...


7

Your analysis so far is generally correct. The way a shell might set the stdin of a process to a pipe descriptor could be (pseudocode): pipe(p) // create a new pipe with two handles p[0] and p[1] fork() // spawn a child process close(p[0]) // close the write end of the pipe in the child dup2(p[1], 0) // duplicate the pipe descriptor on top of fd 0 ...


7

I think it is because this line No valid EAOPL-handshake + ESSID detected. is probably standard error of the pyrit command, not standard out. Normally, | pipes standard out to the next command, with the standard error written immediately to the terminal. Instead, if you want to pass both standard error and out through the pipe, then you can use |&. ...


6

From http://www.gnu.org/software/bash/manual/bashref.html#Pipelines Each command in a pipeline is executed in its own subshell So, you are altering a variable in a subshell. When the subshell exits, those alterations vanish. You may find process substitutions helpful. append_numbered_hooks () { while IFS= read -rd '' hookline; do append_hook ...


4

Yes, this is job for tee: rpm -qa | tee file | wc -l In this construction a | b a's stdout goes to stdin of b. In case of a > file | b all output form a goes to file and nothing goes to b stdin. tee command make a copy of all it receives on stdin to both file and stdout.


3

You can use read and simply do the following while read -r memfree do printf '%s\n' "$memfree" done < <(awk -F: '/MemFree/{print $2}' /proc/meminfo)


3

Yes, this is a job for tee: rpm -qa | tee file | wc -l Shell redirection (>) is just that — redirection — and you can only point the output stream to one other place at a time. There's nothing left for the | to see at that point. tee is made for just this purpose, where you want to split the stream into two parts, one going into a file and one still on ...


2

$ printf "co\u00ebfficient\n" coëfficient Or if you want to do the substitution on a stream: perl -CS -pe 's/\\u(....)/chr hex $1/eg'


2

Try saving single values directly to each variable. You can also remove the cat and the tail pipe by using the -m flag with grep: numA=$(grep -m 1 "MemFree" /proc/meminfo | awk '{ print $2 }') numB=$(grep -m 1 "MemFree" /proc/meminfo | awk '{ print $3 }') echo $numA $numB


2

Because the command substitution is run in subshell, so it made no change to the PIPESTATUS variable of the parent shell. From Command Execution Environment documentation: Command substitution, commands grouped with parentheses, and asynchronous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that ...


1

The default syntax for md5sum is: $ md5sum file 068a9a19124df814e52ff5461598cfe4 file To create a checksum file, redirect standard output to a file: $ md5sum file > md5.checksum To verify the file against the checksum file: $ cd path/to/file $ md5sum --check path/to/md5.checksum file: OK That said, m13r's implementations is equally valid.


1

rpm -qa > file ; wc -l file should do what you want.


1

netcat springs to mind; it may be the more sensible choice (given the no-overhead, no compression approach to network communications) on your low-spec receiving machine. A nice usage example can be found here: http://stackoverflow.com/questions/4113986/example-of-using-named-pipes-in-linux-bash


1

You could insert a pv -TC command in your pipe line: cmd1 | pv -TC | cmd2 pv uses its own buffer and -T makes it report how full it is on average on 1 second periods (by default). If it's always 100%, then that means cmd1 is faster at producing output than cmd2 at consuming it. If not, then it's the other way around. Beware that pipes themselves can ...



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