Shell script echo output does not wrap function enhancement instance _linux Shell

Source: Internet
Author: User

This is the 8th/101 script

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

function Echon
{
 echo ' $* ' | awk ' {printf '%s ' $} '
}

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

Echon ()
{
 printf '%s ' ' $* '
}

But What if you don ' t have printf and don ' t want to call awk? Then Use the TR command:

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

This has simply chopping out the carriage return with TR are simple and efficient solution that should to quite Table.
The script is simple, you can use 3 different functions (methods) to implement, the output does not wrap.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.