Many methods to use the echo command on Linux


The echo command (a celebration built-in) is among the really basic commands on Linux. Similar to ls and pwd, you can’t rest on the command line very long without using it. At the same time, echo has several usages that many of us never ever benefit from. So, this post checks out the numerous ways you can utilize this command.What is echo?Basically, echo is a command that will display any text that you ask it to display. However, when you type”echo hey there”, the echo command isn’t only spitting out those five letters, it’s actually sending 6 characters– the last one being a linefeed. Let’s take a look at a couple of commands that make this obvious.First, utilizing echo without any arguments does this:$echo$Notification that an empty line is shown before the timely comes back. If you redirect the command’s output to the od-bc command, it’s easy to confirm that the “undetectable”output is simply a linefeed– that n or octal 012 in the output listed below. $echo|od-bc 0000000 012 n 0000001 That n is the reason that the echo command can also be used to include a linefeed to the

end of a file that, for some factor, does not have one. Here’s a file that lacks a linefeed followed by the command that adds one.$od-bc nolinefeed 0000000 150 145 154 154 157 h e l o 0000005 $echo >> nolinefeed$ od -bc nolinefeed 0000000 150 145 154 154 157 012 h e l o n datafile Emptying files The echo command can likewise be utilized to empty files. While it’s more common to use a command such as feline/ dev/null > filename, the command echo-n > filename works as well. Both commands change the material of a file with … absolutely nothing! To turn this command into an alias, use a command like this or add it to your.bashrc file. $alias empty=’echo- n >’After setting up the alias, you can simply type a command such as”empty myfile”, and the file will no longer have material.

Keep in

mind … Source

Leave a Reply

Your email address will not be published. Required fields are marked *