Echo Command in Linux with Examples
The reverberation order is one of the most fundamental and every now and again utilized orders in Linux. The contentions passed to repeat are printed to the standard yield.
reverberation is usually utilized in shell contents to show a message or yield the consequences of different orders.
reverberation is a shell builtin in Bash and a large portion of the other mainstream shells like Zsh and Ksh. Its conduct is marginally unique in relation to shell to shell.
There is additionally an independent/usr/canister/reverberation utility, yet generally, the shell worked in variant will come first. We will cover the Bash builtin adaptation of reverberation.
The linguistic structure for the reverberation order is as per the following:
echo [-neE] [ARGUMENTS]
When the - n alternative is utilized, the following newline is smothered.
On the off chance that the - e alternative is given, the accompanying oblique punctuation line got away from characters will be deciphered:
- \\ - Displays an oblique punctuation line character.
- \a - Alert (BEL)
- \b - Displays a delete character.
- \c - Suppress any additionally yield
- \e - Displays a departure character.
- \f - Displays a structure feed character.
- \n - Displays another line.
- \r - Displays a carriage return.
- \t - Displays an even tab.
- \v - Displays a vertical tab.
The - E choice debilitates the understanding of the departure characters. This is the default.
There are a couple of focuses to consider when utilizing the reverberation order.
The shell will substitute all factors, trump card coordinating, and extraordinary characters prior to passing the contentions to the reverberation order.
Albeit redundant, it is a decent programming practice to encase the contentions passed to repeat in twofold or single statements.
When utilizing single statements '' the strict estimation of each character encased inside the statements will be protected. Factors and orders won't be extended.
The accompanying models tell the best way to utilize the reverberation order:
Show a line of text on standard yield.
echo Hello, World!
Show a line of text containing a twofold statement.
To print a twofold statement, wall it in inside single statements or departure it with the oblique punctuation line character.
echo 'Hello "Linuxize"'
echo "Hello \"Linuxize\""
Show a line of text containing a solitary statement.
To print a solitary statement, wall it in inside twofold statements or utilize the ANSI-C Quoting .
echo "I'm a Linux user."
echo $'I\'m a Linux user.'
I'm a Linux user.
Show a message containing uncommon characters.
Utilize the - e choice to empower the understanding of the break characters.
echo -e "You know nothing, Jon Snow.\n\t- Ygritte"
You know nothing, Jon Snow. - Ygritte
Example coordinating characters.
The reverberation order can be utilized with design coordinating characters, for example, the special case characters. For instance, the order underneath will restore the names of all the .php documents in the current catalog.
echo The PHP files are: *.php
The PHP files are: index.php contact.php functions.php
Redirect to a file
Rather than showing the yield on the screen, you can divert it to a document utilizing the >, >> administrators.
echo -e 'The only true wisdom is in knowing you know nothing.\nSocrates' >> /tmp/file.txt
On the off chance that the file.txt doesn't exist, the order will make it. When utilizing > the record will be overwritten, while the >> will annex the yield to the document .
Utilize the feline order to see the substance of the document:
The only true wisdom is in knowing you know nothing. Socrates
reverberation can likewise show factors. In the accompanying model, we'll print the name of the right now signed in client:
$USER is a shell variable that holds your username.
Showing yield of an order
Utilize the $(command) articulation to incorporate the order yield in the reverberation's contention. The accompanying order will show the current date :
echo "The date is: $(date +%D)"
The date is: 04/17/19
Showing in shading
Use ANSI get away from arrangements to change the frontal area and foundation tones or set content properties like underscore and intense.
echo -e "\033[1;37mWHITE" echo -e "\033[0;30mBLACK" echo -e "\033[0;34mBLUE" echo -e "\033[0;32mGREEN" echo -e "\033[0;36mCYAN" echo -e "\033[0;31mRED" echo -e "\033[0;35mPURPLE" echo -e "\033[0;33mYELLOW" echo -e "\033[1;30mGRAY"
At this point, you ought to have a decent comprehension of how the reverberation order functions.
On the off chance that you have any inquiries or input, don't hesitate to leave a remark.
Particle is an open-source cross-stage code manager created by GitHub. It has an inherent bundle chief, inserted Git control, keen autocompletion, ...
An HTML editor is a software for enhancing HTML, the markup of an internet web page. It stands for Tiny Moxiecode Content Editor. TinyMCE is a effe...
Redis is an open-source in-memory key-esteem information store. It tends to be utilized as an information base, store and, message representative, ...
phpMyAdmin is an open-source PHP based instrument for overseeing MySQL and MariaDB workers over an online interface. phpMyAdmin permits you ...
While diverting the yield of an order to a document or funneling it to another order, you may see that the blunder messages are imprinted on the sc...
Deb is the establishment bundle design utilized by all Debian based dispersions. The Ubuntu vaults contain a huge number of deb bundles that...
CodeIgniter Subquery: This tutorial will explain you how to write subquery in codeigniter using active records. SubQuery is a query ...
Hi! In this tutorial we'll see how to find codeigniter version you are using. For pros it may sound basic but would be a challenge fo...
R is an open-source programming language and free climate that has practical experience in factual figuring and graphical portrayal. It is principa...
FTP (File Transfer Protocol) is a standard customer worker network convention that permits clients to move documents to and from a distant organiza...
Cup is a free and open-source miniature web system for Python intended to assist engineers with building secure, adaptable and viable web applicati...
Docker Compose is an instrument that permits you to characterize and arrange multi-holder Docker applications. It utilizes a YAML document to arran...
Spotify is a computerized music real time feature that gives you moment admittance to a great many melodies, from old works of art to the most rece...
sudo is an order line program that permits confided in clients to execute orders as root or another client. In this article we'll show b...
PHP is one of the most utilized worker side programming dialects. Numerous well known CMS and structures, for example, WordPress, Magento, and Lara...
Apache Maven is an open-source venture the executives and perception device utilized principally for Java ventures. Expert uses a Project Object Mo...
twist is an order line utility for moving information from or to a far off worker. With twist, you can download or transfer information utilizing o...
Vim/Vi is the word processor of decision for some product designers and Linux framework chairmen. As a matter of course, Vim doesn't sho...
Trade is a space on a plate that is utilized when the measure of actual RAM memory is full. At the point when a Linux framework runs out of RAM, in...