V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
hazard
V2EX  ›  问与答

这个 alias 怎么写?

  •  
  •   hazard · Apr 6, 2014 · 3349 views
    This topic created in 4404 days ago, the information mentioned may be changed or developed.
    命令是这样的:
    ps aux | grep "exe" | awk '{print $2}' | xargs kill
    我这样写,bash报错:
    alias killwine='ps aux | grep \"exe\" | awk \'\{print \$2\}\' | xargs kill'

    请问该如何写?有哪些资料可以参考?谢谢!
    5 replies    1970-01-01 08:00:00 +08:00
    skydiver
        1
    skydiver  
       Apr 6, 2014
    里面都用双引号,最外面用单引号
    hazard
        2
    hazard  
    OP
       Apr 6, 2014
    @skydiver 如果我想保持单引号,该怎么做?
    skydiver
        3
    skydiver  
       Apr 7, 2014
    @hazard 哦,貌似这个是因为有管道所以不行。。你别用alias了,直接写个function吧
    simple_plan
        4
    simple_plan  
       Apr 7, 2014
    一样的需求
    一开始也是直接写alias 调了半天一直不行。
    后来就上function 然后alias再调用了
    efi
        5
    efi  
       Apr 7, 2014
    pkill -f exe
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   994 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 181ms · UTC 20:12 · PVG 04:12 · LAX 13:12 · JFK 16:12
    ♥ Do have faith in what you're doing.