IconIcon

Friday 21 February 2014

Hacking linux shell

The terminal is interactive utility by that a user interacts with the shell environment.
Printing text within the terminal may be a basic task that the majority shell scripts and utilities ought to perform often.



techntips.net


Printing in the terminal/shell

echo is that the basic command for printing within the terminal.
echo prints statements and results
Example
$ echo "Welcome to Bash"
output will be ---- Welcome to Bash


Hence, if you wish to print special characters like !, within double quotes
then you need to use (\) before special character

Example- To print-- Hello world !

 echo "Hello world \!"



Printing coloured output in terminal


Producing a coloured output on the terminal is incredibly attention-grabbing and is achieved by using - \
You can use Colors color codes for linux shell, some examples being, reset = 0, black = 30, red = 31,
green = 32, yellow = thirty three, blue = 34, magenta = 35, cyan = 36, and white = 37
For example-- echo -e "\e[1;31m This is red text \e[0m"

In above example-- Here, \e[1;31m is that the escape string that sets the colour to red and \e[0m resets the colour
back. Replace thirty one with the specified code.

For a coloured background you can use these colour codes, reset = 0, black = 40, red = 41, green = 42, yellow = 43, blue = 44,
magenta = 45, cyan = 46, and white=47


example-- echo -e "\e[1;42m Green Background \e[0m"


Playing with time

You can delay executiion of script in linux shell using sleep command

Example- to delay for 5 seconds. Use command-- sleep 5






Send us your feedback and your articles.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...