How can I redirect the output of the “time” command?
no need to launch sub shell. Use a code block will do as well. { time ls; } 2> out.txt or { time ls > /dev/null 2>&1 ; } 2> out.txt
no need to launch sub shell. Use a code block will do as well. { time ls; } 2> out.txt or { time ls > /dev/null 2>&1 ; } 2> out.txt
Not only the recursion depth of find can be controlled by the -maxdepth parameter, the depth can also be limited from “top” using the corresponding -mindepth parameter. So what one actually needs is: find . -mindepth 1 -type d
This probably isn’t the answer you’re looking for, but you can’t. Mac OS X sed has no option to show the version number. There is not even a version number in the binary: $ strings $(which sed) $FreeBSD: src/usr.bin/sed/compile.c,v 1.28 2005/08/04 10:05:11 dds Exp $ $FreeBSD: src/usr.bin/sed/main.c,v 1.36 2005/05/10 13:40:50 glebius Exp $ $FreeBSD: src/usr.bin/sed/misc.c,v … Read more
See man find. (particular the part about -exec) When using -exec to run a command on each of the files found, the {} is replaced with the name of each file found, and the command is terminated by \; In your example, all files found under the current directory (.), matching the name *.clj will … Read more
It seems that you have Windows style line endings (\r\n) – you need to change them to unix style (\n). If you have dos2unix installed you could use it. You could also do it using sed or awk.
You must wrap the $@ in quotes, too: “$@” This tells the shell to ignore spaces in the arguments; it doesn’t turn all arguments into a very long string.
Use tail’s –pid option and tail will stop when the shell dies. No need to add extra to the tailed file. sh -c ‘tail -n +0 –pid=$$ -f /tmp/foo | { sed “/EOF/ q” && kill $$ ;}’
Previously, the answer was presented with what’s now the first section as the last section. POSIX Shell includes a ! operator Poking around the shell specification for other issues, I recently (September 2015) noticed that the POSIX shell supports a ! operator. For example, it is listed as a reserved word and can appear at … Read more
If all lines in the input file are of this format, then simply sourcing it will set the variables: source nameOfFileWithKeyValuePairs or . nameOfFileWithKeyValuePairs
From documentation of set -e: When this option is on, if a simple command fails for any of the reasons listed in Consequences of Shell Errors or returns an exit status value > 0, and is not part of the compound list following a while, until, or if keyword, and is not a part of … Read more