Showing posts with label echo. Show all posts
Showing posts with label echo. Show all posts

Tuesday, November 27, 2012

Fourteenth session of Some of basic UNIX commands that are useful very frequently


In todays session, we will discuss about some more useful commands which are used frequently in UNIX/LINUX based Operating Systems.

df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

As described in previous post, you can get the value of environment variable POSIXLY_CORRECT by echo command.

df filename.jpg

As depicted, above command will shows disk space available on the file system containing 'filename.jpg'. Below is output:

sanny@sanny-Inspiron-3420:~/Desktop$ df filename.jpg
Filesystem    1K-blocks       Used     Available   Use%   Mounted on
/dev/sda6    171485500     3372236  159402232         3%        /


There are some common features available which are used for I/O Redirection.

'<' Input Redirection. This allows one to take input from file rather than standard input (stdin) taken from console.

Ex: tr a x < filename

'>' Output Redirection. This allows one to take output to file rather than standard output (stdout) printed to console.

Ex: ls -a > filename

'|' Pipe This allows one to take one command's output to another commands input.

Ex: ls -a | more

When you are free, dont hesitate to try these and post your feedback. Will discuss about some more useful commands in next posts.



Thursday, October 18, 2012

Thirteenth session of Some of basic UNIX commands that are useful very frequently


Today we will discuss about some more commands that are used very frequently in UNIX/LINUX bases operating systems.

If one want to print value of 'PATH' system variable, then using below command we can achieve it.

echo $PATH$

Above command will displays the value of system variable 'PATH'. Its similar to the below command that we use in windows based operating systems.

echo %PATH%

Below is sample output:

$ echo $PATH$
/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)....


Like wise, if one want to display value of any system variable or user defined system variable like JAVA_HOME, CLASSPATH and CATALINA_HOME etc.., then he/she can achieve it as specified above.

To confirm what you are thinking in your mind to execute the same, below is one more similar example for displaying value of 'JAVA_HOME' ( one can also say that Java installed directory):

echo $JAVA_HOME$

Hmmmmmmmm...... yes, your thought is correct. Its similar to echo %JAVA_HOME% that we use in windows based operating systems to know Java installed directory.

If the variable that you want to know the value is not set in your system, then you will get result as an empty string ''. Below is sample illustration:

$ echo $JAVA_HOME$
$


Please feel free to try this. If you already got a chance to work with, then share your thoughts....

Can guess your next thought??????? to modify corresponding system variable (PATH, JAVA_HOME etc..).. how it can be achievable??? Don't worry, we can discuss about this in next post.. will keep posting...

Wednesday, October 17, 2012

Twelfth session of Some of basic UNIX commands that are useful very frequently


Today we will discuss about some more commands that are used very frequently in UNIX/LINUX based systems.

echo is a command used to print any argument that we give. Basically this command is very useful when one want to write shell script(.sh) like batch script(.bat) that we used to write in Windows based systems.

echo argument

Above command will display 'argument' in the terminal. So, while writing shell script and want to debug/log user given argument then, we use this. Its similar to 'System.out.println' that we use in Java to print some thing.

file is a command used to determine type of file by examining its content.

file .bash_profile

Above command will display classification of file named '.bash_profile' present in home directory i.e. /home/ by examining its content. Below is its output:

$ file .bash_profile
.bash_profile: ASCII text


head is a command used to display first few lines of file specified as an argument.

head filename

Above command will display first few lines of a file named 'filename' present in current working directory. Below is output of head command executed on file named 'terimerilyrics':

$ head terimerisonglyrics
Aa......

Teri meri, meri teri prem kahani hai mushqil
Do lafzoon mein yeh bayaan na ho paaye
Ik ladka ik ladki ki yeh kahani hai nayi
Do lafzoon mein yeh bayaan na ho paaye

Teri meri, meri teri prem kahani hai mushqil
Do lafzon mein yeh bayaan na ho paaye
Ik dooje se huey juda Jab ik dooje ke liye bane


As conveyed in previous posts, don't hesitate to try these commands. We will discuss about some more useful commands in next posts.