在bash别名变量代换 [英] variable interpolation in bash alias

查看:97
本文介绍了在bash别名变量代换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有别名:
别名ASD ='MYVAR = $ 1回声\\嘿$ MYVAR再见\\

I have alias: alias asd='myvar=$1 echo \"Hey $myvar Bye\"'

但是,当我运行命令ASD 44我得到的输出嘿再见44.有人能解释为什么回声最后运行,我如何能得到嘿44再见

But when I run the command asd 44 I get the output "Hey Bye" 44. Can someone explain why the echo is run last and how I can get the desired result of "Hey 44 Bye"

推荐答案

别名不做位置扩张;使用函数来代替。

这篇关于在bash别名变量代换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆