zoukankan      html  css  js  c++  java
  • What's the difference between

    bash中看到这样的命令,

    curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
    sudo apt-get install -y nodejs

    黄色部分,| 这个是管道操作符,表示前面命令的输出作为后面的命令的输入。 "bash -" bash 跟一个短杠的作用是什么呢?
    For a command, if using - as an argument in place of a file name will mean STDIN or STDOUT.

    参考:https://askubuntu.com/questions/813303/whats-the-difference-between-one-hyphen-and-two-hyphens-in-a-command

    ---------------------------------------------------------

    Generally:

    • - means to read the argument/content from STDIN (file descriptor 0)

    • -- means end of command options, everything follows that are arguments

    Why needed:

    About -:

    1. $ echo foobar | cat -

    2. foobar

    Although cat can read content from STDIN without needing the -, many commands need that and their man pages mention that explicitly.

    Now about --, I have created a file -spam, let's cat the file:

    1. $ echo foobar >-spam

    2. $ cat -spam

    3. cat: invalid option -- 'p'

    4. Try 'cat --help' for more information.

    5. $ cat -- -spam

    6. foobar

    Without --, cat takes s, p, a, m all as it's options as they follow -, -- explicitly indicates the end of option(s), after that -spam is taken as a file name.

  • 相关阅读:
    UIImageView变灰
    IOS 瀑布流
    IOS9适配 MARK
    MAC PHP MARK
    IOS第三方库 MARK
    IOS聊天对话界面
    UILabel自适应宽度的函数详解
    UIControl的使用
    IOS @2X.png
    自定义UIAlertView
  • 原文地址:https://www.cnblogs.com/cute/p/12603944.html
Copyright © 2011-2022 走看看