Category Archives: Linux

Linux : sort command

I have a file called test.txt
File content ->

1 2 3
3 2 1
2 3 1
2 1 3

If we want to sort it on the first column/field

$ sort +0 -1 test.txt
1 2 3
2 1 3
2 3 1
3 2 1

Sort on the second field/column

$ sort +1 -2 test.txt
2 1 3
1 2 3
3 2 1
2 3 1

On third column

$ sort +2 -3 test.txt
2 3 1
3 2 1
2 1 3
1 2 3

Sort on the first and the second column
2 3 1
3 2 1
2 1 3
1 2 3
We should get the 1 2 3 as the first row, because 1 2 is the lowest

$ sort +0 -2 test.txt
1 2 3
2 1 3
2 3 1
3 2 1

Sort it on second and third columns

$ sort +1 -3 test.txt
2 1 3
3 2 1
1 2 3
2 3 1

If we want to specify a separator (default space)

sort -t <separator> <file>
Advertisements
Tagged

LINUX : Installing Erlang

Create directories for Erlang

~]# mkdir /usr/local/erlang
~]# mkdir /usr/local/erlang/<version:otp_r15b>

Untar the archive into the directory you just created

otp_r15b]# tar -zxvf otp_src_<version:R15B>.tar.gz  

Configure.

otp_src_R15B]# ./configure

make and make install

otp_src_R15B]# make
otp_src_R15B]# make install

Set Path

otp_src_R15B]# vim /etc/profile

Add following lines to the end of the file.

# ERLANG
ERL_TOP=/usr/local/lib/erlang; export ERL_TOP
PATH=$ERL_TOP/bin:$PATH; export PATH

Linux : Installing GCC from RHEL disk

~]# mount -t auto /dev/dvd /mnt/dvdrom/
~]# cd /mnt/dvdrom/Server/
Server]# rpm -ivh gcc-4.1.2-46.el5.i386.rpm

Dependencies

Server]# rpm -ivh glib-1.2.10-20.el5.i386.rpm
Server]# rpm -ivh libgomp-4.4.0-6.el5.i386.rpm
Server]# rpm -ivh glib-devel-1.2.10-20.el5.i386.rpm
Server]# rpm -ivh kernel-headers-2.6.18-164.el5.i386.rpm
Server]# rpm -ivh glibc-headers-2.5-42.i386.rpm 
Server]# rpm -ivh glibc-devel-2.5-42.i386.rpm 
Server]# rpm -ivh gcc-4.1.2-46.el5.i386.rpm

Unmount

~]# umount /mnt/dvdrom

Check gcc

~]# which gcc

rpm

-i – install
-v – verbose
-h – show hash
-U – update

Linux : Mounting DVD rom

~]# mkdir /mnt/dvdrom
~]# mount -t auto /dev/dvd /mnt/dvdrom/
~]# ls /mnt/dvdrom
~]# umount /mnt/dvdrom

Linux : Installing Flex SDK

Create a directory for flex

~]# mkdir /opt/flex

Copy the SDK to that directory and unzip.

flex]# unzip flex_sdk_4.6.zip 

Set PATH

~]# vim /etc/profile

Add following lines to the end of the file

FLEX_HOME=/opt/flex; export FLEX_HOME
PATH=$FLEX_HOME/bin:$PATH; export PATH

Linux : Installing JDK rpm

Create /usr/java

~]# mkdir /usr/java

Copy the rpm file to /usr/java directory
Change the permission of the rpm

java]# chmod a+x jdk-<version>-linux-i586-rpm.bin 

Install the JDK

java]# ./jdk-<version>-linux-i586-rpm.bin

Install packages

java]# rpm -iv  <package>

Set PATH

~]# vim /etc/profile

Add the following lines to the end of the file

JAVA_HOME=/usr/java/default; export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH; export PATH

Linux : Creating a shared library

[root@sam c_src]# gcc -fPIC -c example_lib.c
[root@sam c_src]# gcc -shared -o example_lib.so example_lib.o

If there are more .o files need to be in .so file

[root@sam c_src]# gcc -shared -o example_lib.so example_lib.o example_lib1.o
Tagged