Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

shell脚本echo输出不换行功能增强实例

这是第8/101个脚本

There are as many ways to solve this quirky echo problem as there are pages in this book. One of my favorites is very succinct:

function echon
{
 echo "$*" | awk '{ printf "%s" 
echon()
{
 printf "%s" "$*"
}
}' }

You may prefer to avoid the overhead incurred when calling the awk command, however, and if you have a user-level command called printf you can use it instead:

echon()
{
 echo "$*" | tr -d 'n'
}

But what if you don't have printf and you don't want to call awk? Then use the tr command:

[+++]

This method of simply chopping out the carriage return with tr is a simple and efficient solution that should be quite portable.
这个脚本很简单,就是可以用3种不同的函数(方法)来实现,输出后不换行。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
shell脚本echo输出不换行功能增强实例_随笔_内存溢出

shell脚本echo输出不换行功能增强实例

shell脚本echo输出不换行功能增强实例,第1张

shell脚本echo输出不换行功能增强实例

这是第8/101个脚本

There are as many ways to solve this quirky echo problem as there are pages in this book. One of my favorites is very succinct:

function echon
{
 echo "$*" | awk '{ printf "%s" 
echon()
{
 printf "%s" "$*"
}
}' }

You may prefer to avoid the overhead incurred when calling the awk command, however, and if you have a user-level command called printf you can use it instead:

echon()
{
 echo "$*" | tr -d 'n'
}

But what if you don't have printf and you don't want to call awk? Then use the tr command:

This method of simply chopping out the carriage return with tr is a simple and efficient solution that should be quite portable.
这个脚本很简单,就是可以用3种不同的函数(方法)来实现,输出后不换行。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/3343237.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-10-06
下一篇 2022-10-06

发表评论

登录后才能评论

评论列表(0条)

保存