proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« 最新版 windump nmap 及 windump 使用方法 | Main | 折腾 C 指针 完成 log 过滤 思路清晰是王道 »

November 26, 2006

shell 折腾之 ${!varname} 实现级联调用

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2006/11/26/001146.html
http://windtear.net/archives/2006/11/26/001146.html

shell 折腾之  ${!varname} 实现级联调用

K core 前天出了个题:
bash中如何实现 $ $varname的功能
就是$varname=b $b=a这种
要输出a

开始我以为是赋值:
varname=b
eval $varname=a

后来发现是要调用
两个方法:
1. 比较难看但也成功的解法
eval echo \$$vname
2. 正解
${!varname}

eval 把参数组合成命令再执行
http://windtear.net/archives/2006/10/18/001115.html
本blog WWW

Posted by windtear at November 26, 2006 10:55 PM

本站使用中的任何问题,请与 windtear @ windtear.net 联系
Copyright© 1999-2024 Windtear. All rights reserved.