Friday, 5 August 2011

UNIX : echo Command


Use echo command to display text or value of variable.
echo [options] [string, variables...]
Displays text or variables value on screen.
Options
-e Enable interpretation of the following backslash escaped characters in the strings:
\b backspace
\c suppress trailing new line
\n new line
\r carriage return
\t horizontal tab
\\ backslash
For e.g. $ echo -e "Everyday is not \a\t\tSunday\n"

expr 20 %3 - Remainder read as 20 mod 3 and remainder is 2.
expr 10 \* 3 - Multiplication use \* and not * since its wild card.

ls Command:-

-bash-3.00$ ls *
d                dev              Din              first            myfile           opx_PAR_ERI_6as  opx_PAR_ERI_720


-bash-3.00$ ls [def]*
d      dev    first


-bash-3.00$ ls [d-f]*
d      dev    Din    first



$ ls ?   will show all files whose names are 1 character long 
$ ls fo? will show all files whose names are 3 character long and file name begin with fo.
$ ls /bin/[!a-o]
$ ls /bin/[^a-o]

If the first character following the [ is a ! or a ^ ,then any character not enclosed is matched i.e. do not show us file name that beginning with a,b,c,e...o.


No comments:

Post a Comment