map[bool]int{false: 3, true: 14}[foo != 0]1,089 karma · joined March 1, 2007
C, Unix system and shell, Python, X Windows, ARM, ...
map[bool]int{false: 3, true: 14}[foo != 0]Having done :v/tcp/d there's no need to match again with :g/tcp/s... since :%s... will do, besides :g//s... would have done. Also, :g/tcp/s/\S\+\s\+\(\S\+\)\s.*/\1/ mandates a whitespace after the second word so it's not equivalent to the given :%!awk '/tcp/ {print $2}'.
$ pins |
> sed -r '
> :a; s/^([0-9])(.*)\1/\1\2a/; ta; s/[0-9]/a/
> :b; s/a([0-9])(.*)\1/a\1\2b/; tb; s/[0-9]/b/
> s/([0-9])\1/cc/; s/[0-9]/c/
> s/[0-9]/d/
> ' |
> sort | uniq -c | sort -n
10 aaaa
90 aaab
90 aaba
90 aabb
90 abaa
90 abab
90 abba
90 abbb
720 aabc
720 abac
720 abbc
720 abca
720 abcb
720 abcc
5040 abcd
$ $ pins() { seq -f '%04.0f' 0 9999; }
$ pins | egrep -c '(.)\1'
2710
$ pins | egrep -c '(.).*\1'
4960
$However, for your problem, have you considered the terminal's title instead of the top line of the tty? printf '\033]0;foo\007'
sed -r 's/\<./\U&/g; s/ +//g; s/[^a-zA-Z].*//'
would be better. Note, the last s/// doesn't need a g. cat -- * >../foo
given that cat(1posix) does support --.Besides, ken & Co. aren't daft. con would be short for concatenate. :-)
cat file | foo
foo <file
assuming foo only reads stdin so `foo file' isn't possible, is that with the latter the shell will open file for reading on file descriptor 0 (stdin) before execing foo and the only cost is the read(2)s that foo does directly from file.With the needless cat we have cat having to read the bytes and then write(2) them whereupon foo reads them as before. So the number of system calls goes from R to R+W+R assuming all reads and writes use the same block size and more byte copying may be required.
xargs -rd'\n' grep -l "$@" find -name '*.log' -delete $ ls -Q
" spaces "
$ ls | while IFS="\n" read -r f; do ls "$f"; done
spaces
$
For lots of grim detail see David A. Wheeler's http://www.dwheeler.com/essays/fixing-unix-linux-filenames.h... vim $(grep -lr foo | xargs)
is doing? Assuming a missing directory after the `foo' why can't it just be vim $(grep -lr foo .)
I don't see that xargs's default behaviour is adding anything.For
find . -name foo_fn exec sed -i s/foo_fn/bar_fn/g '{}' \;
you may find -exec's + of use. The above has the fork/execve overhead for each file found. find -name '*.[ch]' -exec sed -i 's/\<foo\>/bar/g' {} + find images -name '*.jpg' |
sed 's/\.jpg$//
s/.*/convert -geometry 200x &.jpg &_thumb.jpg/'