美文网首页
Docker in practice: pipe stdin i

Docker in practice: pipe stdin i

作者: Star_C | 来源:发表于2019-08-26 22:36 被阅读0次

    Scenario

    You are on a machine that does not have tr . You want to use tr to quickly edit a file ./my-article.md and delete all "s. You cannot install anything but you can do it with the pre-installed docker

    Solution

    docker run \ # start docker
    --rm \ # remove container after you finish edit
    -i \ # this is IMPORTANT, to allow stdin piped into docker instance
    jare/alpine-vim \ # specify image
    tr -d '"' \ # specify command
    < ./my-article.md \ # pipe the file into docker program, which is tr in this case
    > ./my-article-quotes-removed.md \ # save output to a file in the machine!
    

    相关文章

      网友评论

          本文标题:Docker in practice: pipe stdin i

          本文链接:https://www.haomeiwen.com/subject/jgejectx.html