添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Colocation
    Overview
  • Data Center as a Service
    Solutions for Digital Transformation
  • Hardware as a Service
    Flexible Hardware Leasing
  • Meet-Me Room
    The Interconnectivity Hub
  • Schedule a Tour
    Guided Virtual Data Center Tour
  • Data Center Locations
    Global Data Center Footprint
  • Platform
    Overview
  • Rancher Deployment
    One-Click Kubernetes Deployment
  • Intel Xeon E-2300
    Entry-Level Servers
  • 4th Gen Intel Xeon Scalable CPUs
    Boost Data-Intensive Workloads
  • Alliances
    Technology Partnerships
  • Object Storage
    S3-Compatible Storage Solution
  • Dedicated Servers
    Overview
  • FlexServers
    Vertical CPU Scaling
  • Intel Xeon-E Servers
    Intel Xeon 2200 Microarchitecture
  • GPU Servers
    Servers with NVIDIA Tesla GPUs
  • Dedicated Servers vs. BMC
    Compare Popular Platforms
  • Promotions
    See Available Discounts
  • Buy Now
    See All Servers
  • Managed Private Cloud (MPC)
    Highly Customizable Cloud
  • Data Security Cloud
    Secure-By-Design Cloud
  • Hybrid Cloud
    Multi-Platform Environment
  • Edge Computing
    Globally Distributed Servers
  • Object Storage
    S3 API Compatible Storage Service
  • Bare Metal Cloud
    API-Driven Dedicated Servers
  • Alternative Cloud Provider
    Overcome Public Cloud Limitations
  • Backup Solutions
    Veeam-Powered Services
  • Disaster Recovery
    VMware, Veeam, Zerto
  • Veeam Cloud Connect
    Backup and Replication
  • Managed Backup for Microsoft 365
    Veeam-Powered Service
  • Data Security Cloud
    Secure-by-Design Cloud
  • Encryption Management Platform (EMP)
    Cryptographic Key Management
  • Confidential Computing
    Data-in-Use Encryption
  • Ransomware Protection
    Data Protection and Availability
  • DDoS Protection
    Network Security Features
  • Network Overview
    Global Network Footprint
  • Network Locations
    U.S., Europe, APAC, LATAM
  • Speed Test
    Download Speed Test
  • Blog
    IT Tips and Tricks
  • Glossary
    IT Terms and Definitions
  • Resource Library
    Knowledge Resources
  • Events
    Let's Meet!
  • Newsroom
    Media Library
  • Developers
    Development Resources Portal
  • APIs
    Access Our Public APIs
  • GitHub
    Public Code Repositories
  • echo Command in Linux (With Examples)

    May 20, 2024

    Introduction

    The echo command is a built-in feature in Linux that prints out its arguments as standard output. It is used to display text strings or the command results.

    This tutorial explains different ways to use the echo command in Linux through various examples.

    The echo command has several arguments. The following table presents commonly used echo command options.

    Option Description
    -n Displays the output while omitting the newline after it.
    -E The default option. Disables the interpretation of escape characters.
    -e Enables the interpretation of escape characters.
    --help Displays a help message with information about the echo command and its options.
    --version Prints the echo command version information.

    echo Command Examples

    The echo command prints text or variables in the terminal. It's commonly used in scripts and command-line operations to provide feedback, print messages, or output variable values. The following text presents ways to use the echo command in Linux.

    Printing a String

    Run the following command to print Hello, World! as the output:

    echo Hello, World!

    The -e option is used with escape characters, as it enables their use in the output. The escape characters are useful for formatting output and adding special characters or effects to text displayed by the echo command. Escape characters used with the -e option are presented in the table below.

    Escape Character Description
    \\ Displays a backslash character.
    \a Plays a sound alert when displaying the output.
    \b Removes all the spaces between the text.
    \c Omits any output following the escape character.
    \n Adds a newline character to the output, which signifies the end of one line of text and the beginning of a new line.
    \r Performs a carriage return, which moves the cursor to the beginning of the current line without advancing to the next line.
    \t Creates horizontal tab spaces.
    \v Creates vertical tab spaces.

    For instance, using \c lets you shorten the output by omitting the part of the string that follows the escape character:

    echo -e 'Hello, World! \c This is PNAP!'

    For more Linux commands, check out our Linux Command Cheat Sheet .

    Was this article helpful?
    Yes No
    Sara Zivanov
    Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
    Next you should read
    DevOps and Development SysAdmin Web Servers How to Use the Linux sleep Command with Examples
    February 3, 2021
    The sleep command is used when it is necessary to postpone the execution of commands on the command line or...
    Read more SysAdmin How to Use the Linux tee Command
    December 3, 2024
    By default in Linux, a command received through standard input writes directly to standard output...
    Read more Security SysAdmin How To Use The Passwd Command In Linux
    January 26, 2021
    Passwords are the most important feature of security. This article explains and shows examples of how to use...
    Read more SysAdmin Web Servers Linux Commands Cheat Sheet: With Examples
    November 2, 2023
    A list of all the important Linux commands in one place. Find the command you need, whenever you need it or...
    Read more