小编g_s*_*sue的帖子

使用管道作为参数的别名命令

我想在我的~/.bash_profile遗嘱中创建一个别名:

  1. 取两个参数 $1 $2
  2. 将这些传递给 diff
  3. 管道输出到 less

我还没有在 Stack 上找到任何可以满足我需要的解决方案,但请向我指出您知道的任何解决方案!以下几行出现在 my 中~/.bash_profile

alias reload='. ~/.bash_profile'
alias aliases='emacs ~/.bash_profile; reload'
function dif () { diff "$1" "$2" | less; }
alias different='dif' 
Run Code Online (Sandbox Code Playgroud)

当我尝试:

gsuehr$ reload
-bash: /Users/gregorysuehr/.bash_profile: line 93: syntax error: unexpected end of file 
Run Code Online (Sandbox Code Playgroud)

我确定我不了解如何使用 bash 函数。reload aliases如果我注释掉函数声明,我已经确认 2 个别名:按预期工作。任何人都可以分享有关以下方面的知识:

  1. 为什么会出现EOF错误?
  2. 如何使用 bash 中的函数来完成我在这里尝试的操作?

bash alias

2
推荐指数
1
解决办法
7177
查看次数

标签 统计

alias ×1

bash ×1