Tuesday, March 13, 2012

Different ways to capitalize the contents of a file


   In this article, we will see the different ways in which we can capitalize the contents of the file and also the other way around. In other words, this will tell how to convert the lowercase characters or string into upper case and upper case into lower case.

Let us take a sample file, "file1", with the following contents:
$ cat file1
hello
welcome
string

Monday, March 12, 2012

Retrieve table names from Oracle queries


    Sometimes, you might have a requirement where you have a file full of Oracle sql queries, and you want to filter out the table names alone. In this article, we are going to look into a Perl script which is for this very purpose.  Given a file with sql queries which could be comprising of SELECT, UPDATE, INSERT or DELETE statements, the script will parse the sql query file and list out the table names alone.

Thursday, March 8, 2012

typeset - arithmetic operations

   typeset is one of those many beautiful commands which is highly underused. In simple words, typeset is the one which is used to declare variables. Interesting!! We do not usually declare variables in Shell, isn't it? Let us see in the article the use of typeset.
   typeset command has different options to use with, but we are going to discuss only the "-i" option in this article.

1. Assignment
$ typeset -i x 

Wednesday, March 7, 2012

Disk Usage and Free Space- Housekeeping

  File system and directories should be kept clean and tidy, else they can anytime messup. Say, you get a mail from your system admin saying the filesystem is full, and asking you to clean up the files. Or say your TL comes and stands next to you asking you to free some space in your account so as to get some free space.How do we do it?  In this article, we will see about these house keeping stuffs.

1. How do you find out the file system capacity or free space?

The df command lists all the filesystems in the system. Infact, df -h gives more readable output:
$ df -h
Filesystem   Size  Used   Avail Use%  Mounted on
/dev/dev1    97G   6.0G   86G   7%    /
/dev/dev2    97G   96G     1G   99%   /home


Thursday, March 1, 2012

15 different ways to display the contents of a file

  Looking at the file contents is one such activity which a UNIX developer might be doing in sleep also. In this article, we will see the umpteen different ways in which we can display or print the contents of a file.

Let us consider a file named "a", with the following  contents:
a
b
c
1. The first is the most common cat command:
$ cat a
a
b
c