echo command in linux and their options | Pro Tech guides

echo command in linux and their options

echo command in Linux allows you to display the text or string that are passed as an argument. You can also use an escape sequence with echo.

Linux command echo with flags and examples

echo command
echo command

Hello guys in this session I'm going to show you how you can use "echo command" in Linux.

And I'm also going to show you how we can declare variables and how we can use these variables with our "echo command".

let's get started,

Simple echo command

simple echo command
simple echo command

$echo Your text

First of all, To use "echo command" you just use "echo" and then some text.

For example hello world and press ENTER. And what it does according to its name it just displayed whatever you write after this "echo command".

So it echoes anything which you write after this keyword "echo".

Now you may say that it's good for nothing because it's just echoing whatever we write after this and it's not really useful.

But the use of this "echo command" comes when you are using some scripting.

For example bash scripting and then it becomes really important sometimes to use "echo" and maybe in the next session, I will show you a brief introduction to scripting also and then you will be able to understand how echo is important.


create a variable using echo

creating a variable
create a variable

$variableName=value

How to use variables in terminal or in Linux. In order to declare a variable you just need to give a name to your variable.

For example "myvariable" and then give equals to sign (=) So it's important here to note that I'm not providing any space between the variable name and equal to symbol.

So don't provide any space in between and then give any value to your variable.

For example, I will give "mark" and when you press ENTER. It does nothing but whenever you want to know the value of this variable.

$echo $variableName

You can use "echo" and then the dollar symbol ($) and then the name of your variable.

For example "myvariable" and press ENTER and it will display the content of this variable.

This variable is only valid for this session of the terminal. As soon as you will close the terminal then your variable value will be gone.

So it's only valid for this session of the terminal.

Escape sequence in echo

escape sequence in linux
escape sequences

$echo -e 'yourContent with escape sequence'
There are some options you can use with "echo".

For example, I will just use echo and then I will use the "-e" flag for escape and then I will use single quotes (').

Within the single quotes (') I will write some text.

Whenever you will give this flag called "-e" it will enable interpretation of backslash as an escape sequence.

Some escape sequence is,

  • "\n" - Newline
  • "\t" - Horizontal Tab
  • "\v" - Vertical Tab
  • "\b" - Backspace

So whenever you want to use backslashes or escape sequence. You can use "-e" as a flag.

Conclusion

For more sequences, You can search for using "Man command" and you will be good to go.

So this is how you can use "echo" and you can declare variables in Linux.

I hope you enjoyed this tutorial please rate comment and bye for now.

HAVE A NICE DAY💖

Name

Apps,3,Games,1,Linux,38,Linux Commands,37,Network-Devices,1,Networking,1,Terminal Apps,2,Termux,17,Userland,3,Windows,1,
ltr
item
Pro Tech guides: echo command in linux and their options
echo command in linux and their options
echo command in Linux allows you to display the text or string that are passed as an argument. You can also use an escape sequence with echo.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjof6_8MASPxrplX45gTyayyMyehInfvrVxELjR_tBGF1K2AfRWRkzi_tBzXmIB7VYxUs1Tp0tyILMCYN2wABSiuqDwtgkn1MxEecyGJprLvssxeOTcA9zdFT4y451AwCq9LJ2wgNG-KxM/s16000/echo+command+in+linux.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjof6_8MASPxrplX45gTyayyMyehInfvrVxELjR_tBGF1K2AfRWRkzi_tBzXmIB7VYxUs1Tp0tyILMCYN2wABSiuqDwtgkn1MxEecyGJprLvssxeOTcA9zdFT4y451AwCq9LJ2wgNG-KxM/s72-c/echo+command+in+linux.jpg
Pro Tech guides
https://devops-digest.blogspot.com/2020/12/echo-command-in-linux-and-their-options.html
https://devops-digest.blogspot.com/
https://devops-digest.blogspot.com/
https://devops-digest.blogspot.com/2020/12/echo-command-in-linux-and-their-options.html
true
7053638852026728047
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content