开发者

What shell feature did surprise you? [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

开发者_运维百科 Improve this question

So I thought I was an old fart who knew his Bourne/POSIX shell inside out. Still, sometimes I am surprised when I learn of a new feature. Even happens after 25 years. Examples:

Optional open parens for patterns in case statements:

case $foo in
    (bar) foobar;;
    (baz) foobaz;;
esac

Makes my vi % motion command happy as the parentheses are now symmetric!

Redirection can appear anywhere in a simple command, not just after the last arg:

>ls.out ls
>wc.out wc <.profile -l

This can be used to make long pipes look more "natural" as in

<infile cmd1 | cmd2 | cmd3 >outfile

There can be more than one here-document (even for the same fd):

cat <<EOF1 <<EOF2
  foo
EOF1
  bar
EOF2

Please restrict your answers to plain Bourne and POSIX shells (no bash or zsh specific features, thanks!).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜