• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >linux shell > shell脚本echo输出不换行功能增强实例

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

作者:mdxy-dxy 字体:[增加 减小] 来源:互联网

mdxy-dxy 通过本文主要向大家介绍了shell脚本echo,shell脚本中echo,shell脚本实例,shell脚本编程实例,linux shell脚本实例等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

这是第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" $0 }'
}
</div>

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()
{
 printf "%s" "$*"
}
</div>

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

echon()
{
 echo "$*" | tr -d '\n'
}
</div>

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

</div>

您可能想查找下面的文章:

  • shell脚本echo输出不换行功能增强实例
  • shell中使用echo打印彩色字体和彩色背景的方法
  • Shell脚本echo指令使用小技巧
  • shell脚本中echo显示内容带颜色的实现方法

相关文章

  • Linux 中 RPM包 安装 查询 卸载命令小结及yum命令详解
  • 查找目录下同名但不同后缀名文件的shell脚本代码
  • 一天一个shell命令 linux文本操作系列-head,tail命令详解
  • 获取shell脚本自身所在目录的Shell脚本分享
  • Bash Shell 注释多行的几种方法
  • 实现MySQL定时批量检查表repair和优化表optimize table的shell脚本
  • 虚拟机中使用linux系启用文件共享之后的文件存在的位置方法
  • shell脚本监控系统负载、CPU和内存使用情况
  • Linux进程通信(IPC)方式简介
  • 8个实用的Shell脚本分享

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 一个简单的转换输出的shell脚本代码
    • linux下通过命令行获取gmail的新邮件
    • linux下编译boost.python简单方法
    • linux 命令每天必学之tar命令
    • Shell使用Epoch进行日期时间转换和计算的几个小函数
    • linux动态链接库使用方法分享
    • vtune自动化安装脚本
    • Linux下Tomcat启动正常,但浏览器无法访问的解决方法
    • Shell脚本实现检测某ip网络畅通情况(含短信报警功能)
    • shell脚本编程之if语句学习笔记

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有