Aug 26, 2010

More on Linux commands

If you need to compress a text document you can use;
$gzip textfile.txt
This will convert the txt file to "textfile.gz".
To view a gz file you can use; $zcat

To view diffes between two files we can use;
$diff file1 file2 - in the output of this command < will view the diffes in file1 & > will view the diffes in file2

$find . -name "*.txt" -print ;
This command will find for the file name with ".txt" and print the file path. And also note the "." after the command. It meens the find is running on current directory and in all other sub-directories.

Compiling source code

First create a directory in homedirectory to store the program. Use mkdir command for it.

Then go inside the directory and type;
$./configure -prefix=$HOME/file_name
It will set the instalation path to your destination.
Now type;
This will make the excecutable files
After that we should check the excecutable is working properly. To do that;
$make check
$make install - to install the program.
Now type;
It will run the program.
(* Note:- if you need to run the program by only typing the program name, you mustadd the path of the program to the PATH variable.
$set path=($path ~/directory/bin)

Variables are a kind ofpassing information from the shell to programs when there are running.
There are two types of variables,
1. Environment variables (in UPPER CASE)
2. Shell variables (in lower case)
By using $env command you can view environment variabler with their values.
USER, HOME, PATH and HOST are some environment variables.

No comments:

Post a Comment

Your comments are always welcome ...