相关疑难解决方法(0)

带有单引号和双引号的bash alias命令

我有这个命令做我想要的但我无法在我的.bashrc中对其进行别名(注意它使用单引号和双引号):

svn status | awk '$1 =="M"{print $2;}'
Run Code Online (Sandbox Code Playgroud)

我试过了:

alias xx="svn status | awk '$1 ==\"M\"{print $2;}'"
Run Code Online (Sandbox Code Playgroud)

还有其他一些没有运气的常识组合..我知道bash非常挑剔引号..所以什么是别名的正确方法,为什么?谢谢

linux bash quotes double-quotes

63
推荐指数
3
解决办法
3万
查看次数

转义bash别名中的字符

这是别名:

     # make a tmux session in working dir with the name of the dir
     alias th='tmux new -s $(pwd | tr '\/' '\n' | tail -n 1)'  
Run Code Online (Sandbox Code Playgroud)

由于转义字符或'别名内的单引号,它不起作用.打印出来

    $ type --all th
    th is aliased to `tmux new -s $(pwd | tr / n | tail -n 1)'
Run Code Online (Sandbox Code Playgroud)

看起来它只是剥离了'\.

我最终通过将单引号更改为双引号来修复它.

     # make a tmux session in working dir with the name of the dir
     alias th='tmux new -s $(pwd | tr "\/" "\n" …
Run Code Online (Sandbox Code Playgroud)

unix linux bash aliases .bash-profile

4
推荐指数
1
解决办法
4400
查看次数

标签 统计

bash ×2

linux ×2

.bash-profile ×1

aliases ×1

double-quotes ×1

quotes ×1

unix ×1