Time To Earn

Saturday, November 30, 2013

Difference between AWK and SED command


SED (which stands for Stream EDitor) is a simple but powerful computer program used to apply various pre-specified textual transformations to a sequential stream of text data. It reads input files line by line, edits each line according to rules specified in its simple language (the sed script), and then outputs the line.

AWK is a complete pattern scanning and processing language, it is most commonly used as a Unix command-line filter to reformat the output of other commands.  For example, to print only the second and sixth fields of the date command (the month and year) with a space separating them, at the Unix prompt, you would enter: date | awk ‘{print $2 ” ” $6}’



====================================================


sed reads from standard input and/or file(s), applies specified changes which are typically mostly editing changes, and writes to standard output. It is relatively similar to the text editor
ed(1), except in the case of sed it doesn't alter its input file(s)*, but writes the data to standard output, and sed also has some commands which ed does not have (and in most cases wouldn't be suitable for or make sense for ed). sed's commands are mostly limited to editing type commands.

awk is sort of like an interpreted somewhat C-like language with added built-in functionality for dealing with strings and patterns. Though not a fully general purpose programming language, awk is much closer to such than sed.
 

Unix Interview Questions and Commands

1. How do you find which processes are using a particular file?

By using lsof command in UNIX. It will list down PID of all the processes which are using a particular file.

2. How do you find which remote hosts are connecting to your host on a particular port say 10123?

By using netstat command

For example: execute netstat -a | grep "port" and it will list the entire hosts which are connected to this host on port 10123.

3. How to tell if my process is running in Unix?

You can list down all the running processes using [ps] command. Then you can “grep” your user name or process name to see if the process is running.

4. What is ephemeral port in UNIX?

Ephemeral ports are port used by Operating system for client sockets. There is a specific range on which OS can open any port specified by ephemeral port range.

5. How to list down file/folder lists alphabetically?

Normally [ls –lt] command lists down file/folder list sorted by modified time. If you want to list then alphabetically, then you should simply specify: [ls –l]

6. If one process is inserting data into your MySQL database? How will you check how many rows inserted into every second?

By using "watch" command in UNIX

7. There is a file Unix_Test.txt which contains words "Unix". How will you replace all Unix to UNIX?

By using SED command in UNIX

For example: you can execute sed s/Unix/UNIX/g fileName.

8. You have a tab separated file which contains Name, Address and Phone Number. List down all Phone Number without their name and addresses?

By using either AWK or CUT command.

9. How to check if the last command was successful in Unix?

To check the status of last executed command in UNIX, you can check the value of an inbuilt bash variable [$?]. See the below example:

$> echo $?

10. How to check all the running processes in Unix?

The standard command to see this is [ps]. But [ps] only shows you the snapshot of the processes at that instance. If you need to monitor the processes for a certain period of time and need to refresh the results in each interval, consider using the [top] command.

$> ps –ef

If you wish to see the % of memory usage and CPU usage, then consider the below switches:

$> ps aux

If you wish to use this command inside some shell script, or if you want to customize the output of [ps] command, you may use “-o” switch like below. By using “-o” switch, you can specify the columns that you want [ps] to print out.

$>ps -e -o stime,user,pid,args,%mem,%cpu

11 Your application home directory is full? How will you find which directory is taking how much space?

By using disk usage (DU) command in Unix

For example du –sh . | grep G  will list down all the directories which have GIGS in Size.

12. How do you find for how many days your Server is up?

By using uptime command in UNIX

13. How to check if a file is present in a particular directory in Unix?

Using command, we can do it in many ways. Based on what we have learnt so far, we can make use of [ls] and [$?] command to do this. See below:

$> ls –l file.txt; echo $?

If the file exists, the [ls] command will be successful. Hence [echo $?] will print 0. If the file does not exist, then [ls] command will fail and hence [echo $?] will print 1.

14. You have an IP address in your network. How will you find hostname and vice versa?

By using nslookup command in UNIX

15. How to execute a database stored procedure from Shell script?

$> SqlReturnMsg=`sqlplus -s username/password@database<<EOF
BEGIN
Proc_Your_Procedure(… your-input-parameters …);
END;
/
EXIT;
EOF`
$> echo $SqlReturnMsg

16. How to check the command line arguments in a UNIX command in Shell Script?

In a bash shell, you can access the command line arguments using $0, $1, $2, … variables, where $0 prints the command name, $1 prints the first input parameter of the command, $2 the second input parameter of the command and so on.

17. How to fail a shell script programmatically?

Just put an [exit] command in the shell script with return value other than 0. This is because the exit code of successful Unix program is zero. So, suppose if you write exit -1 inside your program, then your program will throw an error and exit immediately.

18. How to print/display the first line of a file?

There are many ways to do this. However the easiest way to display the first line of a file is using the [head] command.

$> head -1 file.txt

If you specify [head -2] then it would print first 2 records of the file.

Another way can be by using [sed] command. [Sed] is a very powerful text editor which can be used for various text manipulation purposes like this.

$> sed '2,$ d' file.txt

How does the above command work? The 'd' parameter basically tells [sed] to delete all the records from display from line 2 to last line of the file (last line is represented by $ symbol). Of course it does not actually delete those lines from the file, it just does not display those lines in standard output screen. So you only see the remaining line which is the 1st line.]

19. How to print/display the last line of a file?

The easiest way is to use the [tail] command.

$> tail -1 file.txt

If you want to do it using [sed] command, here is what you should write:

$> sed -n '$ p' test

From our previous answer, we already know that '$' stands for the last line of the file. So '$ p' basically prints (p for print) the last line in standard output screen. '-n' switch takes [sed] to silent mode so that [sed] does not print anything else in the output.

20. How to display n-th line of a file?

The easiest way to do it will be by using [sed]. Based on what we already know about [sed] from our previous examples, we can quickly deduce this command:

$> sed –n '<n> p' file.txt

You need to replace <n> with the actual line number. So if you want to print the 4th line, the command will be

$> sed –n '4 p' test

Of course you can do it by using [head] and [tail] command as well like below:

$> head -<n> file.txt | tail -1

You need to replace <n> with the actual line number. So if you want to print the 4th line, the command will be

$> head -4 file.txt | tail -1

21. How to remove the first line / header from a file?

We already know how [sed] can be used to delete a certain line from the output – by using the'd' switch. So if we want to delete the first line the command should be:

$> sed '1 d' file.txt

But the issue with the above command is, it just prints out all the lines except the first line of the file on the standard output. It does not really change the file in-place. So if you want to delete the first line from the file itself, you have two options.

Either you can redirect the output of the file to some other file and then rename it back to original file like below:

$> sed '1 d' file.txt > new_file.txt
$> mv new_file.txt file.txt

Or, you can use an inbuilt [sed] switch '–i' which changes the file in-place. See below:

$> sed –i '1 d' file.txt

22. How to remove the last line/ trailer from a file in Unix script?

Always remember that [sed] switch '$' refers to the last line. So using this knowledge we can deduce the below command:

$> sed –i '$ d' file.txt

23. How to remove certain lines from a file in Unix?

If you want to remove line <m> to line <n> from a given file, you can accomplish the task in the similar method shown above. Here is an example:

$> sed –i '5,7 d' file.txt

The above command will delete line 5 to line 7 from the file file.txt

24. How to remove the last n-th line from a file?

This is bit tricky. Suppose your file contains 100 lines and you want to remove the last 5 lines. Now if you know how many lines are there in the file, then you can simply use the above shown method and can remove all the lines from 96 to 100 like below:

$> sed –i '96,100 d' file.txt   # alternative to command [head -95 file.txt]

But not always you will know the number of lines present in the file (the file may be generated dynamically, etc.) In that case there are many different ways to solve the problem. There are some ways which are quite complex and fancy. But let's first do it in a way that we can understand easily and remember easily. Here is how it goes:

$> tt=`wc -l file.txt | cut -f1 -d' '`;sed –i "`expr $tt - 4`,$tt d" test

As you can see there are two commands. The first one (before the semi-colon) calculates the total number of lines present in the file and stores it in a variable called “tt”. The second command (after the semi-colon), uses the variable and works in the exact way as shown in the previous example.

25. How to check the length of any line in a file?

We already know how to print one line from a file which is this:

$> sed –n '<n> p' file.txt

Where <n> is to be replaced by the actual line number that you want to print. Now once you know it, it is easy to print out the length of this line by using [wc] command with '-c' switch.

$> sed –n '35 p' file.txt | wc –c

The above command will print the length of 35th line in the file.txt.

26. How to get the nth word of a line in Unix?

Assuming the words in the line are separated by space, we can use the [cut] command. [cut] is a very powerful and useful command and it's real easy. All you have to do to get the n-th word from the line is issue the following command:

cut –f<n> -d' '

'-d' switch tells [cut] about what is the delimiter (or separator) in the file, which is space ' ' in this case. If the separator was comma, we could have written -d',' then. So, suppose I want find the 4th word from the below string: “A quick brown fox jumped over the lazy cat”, we will do something like this:

$> echo “A quick brown fox jumped over the lazy cat” | cut –f4 –d' '

And it will print “fox”

27. How to reverse a string in unix?

Pretty easy. Use the [rev] command.

$> echo "unix" | rev

xinu

28. How to get the last word from a line in Unix file?

We will make use of two commands that we learnt above to solve this. The commands are [rev] and [cut]. Here we go.

Let's imagine the line is: “C for Cat”. We need “Cat”. First we reverse the line. We get “taC rof C”. Then we cut the first word, we get 'taC'. And then we reverse it again.

$>echo "C for Cat" | rev | cut -f1 -d' ' | rev

Cat

29. How to get the n-th field from a Unix command output?

We know we can do it by [cut]. Like below command extracts the first field from the output of [wc –c] command

$>wc -c file.txt | cut -d' ' -f1

But I want to introduce one more command to do this here. That is by using [awk] command. [awk] is a very powerful command for text pattern scanning and processing. Here we will see how may we use of [awk] to extract the first field (or first column) from the output of another command. Like above suppose I want to print the first column of the [wc –c] output. Here is how it goes like this:

$>wc -c file.txt | awk ' ''{print $1}'

The basic syntax of [awk] is like this:

awk 'pattern space''{action space}'

The pattern space can be left blank or omitted, like below:

$>wc -c file.txt | awk '{print $1}'

In the action space, we have asked [awk] to take the action of printing the first column ($1).

30. How to replace the n-th line in a file with a new line in Unix?

This can be done in two steps. The first step is to remove the n-th line. And the second step is to insert a new line in n-th line position. Here we go.

Step 1: remove the n-th line

$>sed -i'' '10 d' file.txt       # d stands for delete

Step 2: insert a new line at n-th line position

$>sed -i'' '10 i This is the new line' file.txt     # i stands for insert

31. How to show the non-printable characters in a file?

Open the file in VI editor. Go to VI command mode by pressing [Escape] and then [:]. Then type [set list]. This will show you all the non-printable characters, e.g. Ctrl-M characters (^M) etc., in the file.

32. How to zip a file in Linux?

Use inbuilt [zip] command in Linux

33. How to unzip a file in Linux?

Use inbuilt [unzip] command in Linux.

$> unzip –j file.zip

34. How to test if a zip file is corrupted in Linux?

Use “-t” switch with the inbuilt [unzip] command

$> unzip –t file.zip

35. How to check if a file is zipped in Unix?

In order to know the file type of a particular file use the [file] command like below:
$> file file.txt
file.txt: ASCII text
If you want to know the technical MIME type of the file, use “-i” switch.
$>file -i file.txt
file.txt: text/plain; charset=us-ascii
If the file is zipped, following will be the result
$> file –i file.zip
file.zip: application/x-zip

Awesome Awk One Liners for Unix Interviews

1.To Negate some lines with AWK:

 These are called awk one liners. The First trick for today is how to negate some rows while using awk.

The Trick is : awk -F ” ” ‘NR>5 && NR<7{print $1,$2,$3}’ 1.txt

Note : This question will mostly asked in interviews where you will be asked to print some parameters from a file mostly a log file where in you will be asked to negate some rows herein refered to as records in awk. The above command here performs the following action. The field separator mostly called as delimiter here will be a space and then it will negate all the records and will only iterate through line numbers five through seven and then print the first second and third parameter.

2. To Take only a few Lines:

How would you print only lines match between Rahul and Abhishek using awk? Considering your file names.txt contains :
Rahul
Sahil
Geetika
Mamta
Abhishek
and the expected output should be like :
Sahil
Geetika
Mamta

The Trick is : $ awk ‘/Rahul/{ P=1; next } /Abhishek/ {exit} P’ names.txt

3. Context Addressing in AWK:

The above command will give you the desired output. Just try. If the Interviewer asks you what is this called, Just say this is called the CONTEXT addressing in awk. The interviewer might also be interested in asking you to print a certain range of lines from a file where in you do not have a pattern defined. We all know awk works on the principle of condition { actions }. Where condition is typically an expression and action is a series of commands. The input is split into records, where by default records are separated by newline characters so that the input is split into lines. So we know the context addressing can be used just like grep, so here you go.

The Trick is : awk ‘$0 ~ /pattern/ {print $0}’

4. Taking a range of records:

Suppose one wants to print all the lines in a file that match some pattern, the above code should be used.Lets suppose he wants you to print logs from line number 15000 to 16000.Just give him a simple blunt reply.

The Trick is  : head -16000 filename | tail -1000.

5. Deleting only files :

Now the interviewer might be tempted to ask you to delete all the files in the current directory with awk.

The Trick is  : ls -l|awk ‘$1!~/^drwx/{print $9}’|xargs rm

6. Removing Duplicates without sorting :

Be careful when trying this out in your home directory. This will remove all the files. awk syntax is not the same in every Unix system, but there is a way to learning how is it in our particular system: man awk. Now lets see our last trick, this talks about deleting the duplicate entries in file without sorting. There are thousand ways of doing one thing in unix lets see a couple of them. Suppose your file text.txt has contents the below contents.

/users/env> cat test.txt
abcd
efgh
ijkl
mnop
abcd
/users/env > cat test.txt |awk !’x[$0]++’
abcd
efgh
ijkl
mnop

Now this one lines removes the duplicate without sorting them.

Taken From http://www.computerandyou.net/2012/07/six-simple-and-awesome-awk-one-liners-for-unix-interviews/

AWK Interview Questions 1

Awk is powerful tool in Unix. Awk is an excellent tool for processing the files which have data arranged in rows and columns format. It is a good filter and report writer.
1. How to run awk command specified in a file?
awk -f filename

2. Write a command to print the squares of numbers from 1 to 10 using awk command
awk 'BEGIN { for(i=1;i<=10;i++) {print "square of",i,"is",i*i;}}'

3. Write a command to find the sum of bytes (size of file) of all files in a directory.
ls -l | awk 'BEGIN {sum=0} {sum = sum + $5} END {print sum}'

4. In the text file, some lines are delimited by colon and some are delimited by space. Write a command to print the third field of each line.

awk '{ if( $0 ~ /:/ ) { FS=":"; } else { FS =" "; } print $3 }' filename

5. Write a command to print the line number before each line?
awk '{print NR, $0}' filename

6. Write a command to print the second and third line of a file without using NR.
awk 'BEGIN {RS="";FS="\n"} {print $2,$3}' filename

7. Write a command to print zero byte size files?
ls -l | awk '/^-/ {if ($5 !=0 ) print $9 }'

8. Write a command to rename the files in a directory with "_new" as postfix?
ls -F | awk '{print "mv "$1" "$1".new"}' | sh

9. Write a command to print the fields in a text file in reverse order?
awk 'BEGIN {ORS=""} { for(i=NF;i>0;i--) print $i," "; print "\n"}' filename

10. Write a command to find the total number of lines in a file without using NR
awk 'BEGIN {sum=0} {sum=sum+1} END {print sum}' filename

Another way to print the number of lines is by using the NR. The command is
awk 'END{print NR}' filename 

Monday, November 25, 2013

perl coding

        my $Log_Path;
        my $OPLOG_PATH;
        my $Start_Time_Dur;
        my $End_Time_Dur;
        my $Category ;
        my $op_file ;
        if (scalar @ARGV < 2) {
        die "
        ***********************************************************
        USAGE:
        Option1 : $0 Log_File_Name Flag
        Option2 : $0 Log_File_Name Flag ArrayCounter
        Help :
        perl $0 Log_File_Name --flags

        flags are:

          --Help                Suggests the usage for the script and the flags available
          --Default             1. Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}
                                2. Top ten URL's Response Time wise, Top Ten URL Download Wise, Hourly Frequency of load
          --Hourly              Outputs Hourly hit/response time/download amount from URL's
          --CategoryWise        Outputs category wise hit/response time/download amount from URL's
          --Categ_Hourly        Outputs Hourly as well as Category wise hit/response time/download amount from URL's
          --Download            Outputs download amount from URL's
          --Cat_Download        Outputs Category wise download amount from URL's
          --Hourly_Download     Outputs Hourly download amount from URL's
          --Create_Hourly_Logs  This Creates the Hourly Log as per the requirement
          --All3Ip              Output's 3 ip's which are present at IP field
          --URL                 Output's the unique URL
          --HperIP              Output's Hit's Per Ip
        "
        }
        else {
        $Log_Path = $ARGV[0] || '';
        }
        use strict;
        my $array_counter = $ARGV[2] || '15';
        print "Number of Rows Requested : ".$array_counter."\n";
        my %hash1 = ();
        my @array1;
        my $output_file;
        my @arrays;
        my @hourly_log;
        my $scalar1;
        my %seen = ();
        my $tim;
        my $waqt;
        my $series;
        my $text;
        my @hitsip;
        my @respons;
        my @topten;
        my @qwe;
        my @dada;
        my @highrespo;
        my @all3ip;
        my @sorthosize;
        my @bothvalue;
        my $oneval;
        my @topten_size;
        my @topten_cat_size;
        my @topten_onlycat_size;
        my @sorthousize;
        my @toptensize;
        my @sortsize;
        my @highsize;
        my @sortcat;
        my @sortdowcatonly;
        my @diff_value;
        my @hourly_op;
        my @topt_3;
        my @next3array;
        my $pages;
        my @special;
        my @next3soarray;
        my @sortcatonly;
        my $how;
        my @topten_hourly;
        my @highestsize;
        my @topten_onlycat;
        my %count;
        my @sortcatsize;
        my @topten_cat;
        my @nextarray;
        my @nextsoarray;
        my @sortqwe;
        my @grephours ;
        my @timarr = (1 .. 24);
        my ($begin_time, $end_time, $total_hits);
                my ($Start_Hour,$Start_Min,$End_Hour,$End_Min);
        my ($host, $ident_user, $auth_user, $date, $time, $time_zones, $farji, $farji2i, $farji3, $farji4, $farji5, $farji6, $farji7, $farji8, $farji9, $farji10, $farji11, $farji12) ;
        my ($hour, $min, $sec) ;
        print "Log File Used for Parsing is -->$Log_Path"."\n";
        open (MYFILE,$Log_Path) || die "Error : $!";

        ############### parse command line argument and choose the right request to server ############
                        if ($ARGV[1] =~ "--Hourly") {
                                                        print "Start Time of analysis Period ";
                                                        print "Start Time -->in format of HH:MM --> ";
                                                        chomp($Start_Time_Dur = <STDIN>);
                                                        ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
                                                        if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
                                                        print $Start_Hour."\n" ;
                                                        print $Start_Min."\n" ;
                                                        }
                                                        else {
                                                        print "Start Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        print "End Time of analysis Period ";
                                                        print "End Time --> in format of HH:MM --> ";
                                                        chomp($End_Time_Dur = <STDIN>);
                                                        ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
                                                        if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
                                                        print $End_Hour."\n" ;
                                                        print $End_Min."\n" ;
                                                        }
                                                        else {
                                                        print "End Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        if ($Start_Hour <= $End_Hour) {
                                                        print "This is Right Order Of Time Duration"."\n" ;
                                                        }
                                                        else {
                                                        print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
                                                        exit ;
                                                        }
                                                        if ($End_Hour == 24){
                                                        print "Default Value of End Minute when End Hour is 24"."\n" ;
                                                        $End_Min = 00 ;
                                                        print $End_Min."\n";
                                                        }
                                                        &break_component ;
                                                        &hourly_repso ;
                                                        &hourly_size;
                        } elsif ($ARGV[1] =~ "--Default") {
                                                        print "Shows The Default Behaviour {Top 15 Max Response Time URL and Top 15 Download URL}";
                                                        &break_component ;
                                                        &genral_behav ;
                                                        &hou_only_size;
                                                        &download_wise;
                                                        &cat_only_size;
                        } elsif ($ARGV[1] =~ "--CategoryWise") {
                                                        print " Give Category you want to analyze ";
                                                        chomp($Category = <STDIN>);
                                                        print " Category Choosen --> ".$Category."\n";
                                                        &break_component ;
                                                        &category_wise ;
                                                        &categ_down_wise;
                        } elsif ($ARGV[1] =~ "--Categ_Hourly") {
                                                        print "Start Time of analysis Period ";
                                                        print "Start Time -->in format of HH:MM --> ";
                                                        chomp($Start_Time_Dur = <STDIN>);
                                                        ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
                                                        if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
                                                        print $Start_Hour."\n" ;
                                                        print $Start_Min."\n" ;
                                                        }
                                                        else {
                                                        print "Start Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        print "End Time of analysis Period ";
                                                        print "End Time --> in format of HH:MM --> ";
                                                        chomp($End_Time_Dur = <STDIN>);
                                                        ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
                                                        if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
                                                        print $End_Hour."\n" ;
                                                        print $End_Min."\n" ;
                                                        }
                                                        else {
                                                        print "End Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        if ($Start_Hour <= $End_Hour) {
                                                        print "This is Right Order Of Time Duration"."\n" ;
                                                        }
                                                        else {
                                                        print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
                                                        exit ;
                                                        }
                                                        if ($End_Hour == 24){
                                                        print "Default Value of End Minute when End Hour is 24"."\n" ;
                                                        $End_Min = 00 ;
                                                        print $End_Min."\n";
                                                        }
                                                        print " Give Category you want to analyze ";
                                                        chomp($Category = <STDIN>);
                                                        print " Category Choosen --> ".$Category."\n";
                                                        &break_component ;
                                                        &hourcateg_repso;
                                                        &download_wise;
                                                        &hourly_cat_size;
                        } elsif ($ARGV[1] =~ "--Download") {
                                                        &break_component ;
                                                        &download_wise ;
                                                        &cat_only_size;
                        } elsif ($ARGV[1] =~ "--Cat_Download") {
                                                        print " Give Category you want to analyze ";
                                                        chomp($Category = <STDIN>);
                                                        print " Category Choosen --> ".$Category."\n";
                                                        &break_component ;
                                                        &category_wise ;
                        } elsif ($ARGV[1] =~ "--Hourly_Download") {
                                                        print " Analyze Hourly Download ";
                                                        print "Start Time of analysis Period ";
                                                        print "Start Time -->in format of HH:MM --> ";
                                                        chomp($Start_Time_Dur = <STDIN>);
                                                        ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
                                                        if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
                                                        print $Start_Hour."\n" ;
                                                        print $Start_Min."\n" ;
                                                        }
                                                        else {
                                                        print "Start Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        print "End Time of analysis Period ";
                                                        print "End Time --> in format of HH:MM --> ";
                                                        chomp($End_Time_Dur = <STDIN>);
                                                        ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
                                                        if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
                                                        print $End_Hour."\n" ;
                                                        print $End_Min."\n" ;
                                                        }
                                                        else {
                                                        print "End Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        if ($Start_Hour <= $End_Hour) {
                                                        print "This is Right Order Of Time Duration"."\n" ;
                                                        }
                                                        else {
                                                        print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
                                                        exit ;
                                                        }
                                                        if ($End_Hour == 24){
                                                        print "Default Value of End Minute when End Hour is 24"."\n" ;
                                                        $End_Min = 00 ;
                                                        print $End_Min."\n";
                                                        }
                                                        &break_component ;
                                                        &categ_down_wise;
                                                        &hourly_size ;
                        } elsif ($ARGV[1] =~ "--Create_Hourly_Logs") {
                                                        print " Analyze Category Wise Hourly Download ";
                                                        print "Start Time of analysis Period ";
                                                        print "Start Time -->in format of HH:MM --> ";
                                                        chomp($Start_Time_Dur = <STDIN>);
                                                        ($Start_Hour, $Start_Min) = split /:/, $Start_Time_Dur, 2;
                                                        if ($Start_Hour >= 0 && $Start_Hour <= 24 && $Start_Min >= 0 && $Start_Min <= 60) {
                                                        print $Start_Hour."\n" ;
                                                        print $Start_Min."\n" ;
                                                        }
                                                        else {
                                                        print "Start Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        print "End Time of analysis Period ";
                                                        print "End Time --> in format of HH:MM --> ";
                                                        chomp($End_Time_Dur = <STDIN>);
                                                        ($End_Hour, $End_Min) = split /:/, $End_Time_Dur, 2;
                                                        if ($End_Hour >= 0 && $End_Hour <= 24 && $End_Min >= 0 && $End_Min <= 60) {
                                                        print $End_Hour."\n" ;
                                                        print $End_Min."\n" ;
                                                        }
                                                        else {
                                                        print "End Time Should be in range of 00 to 24 hours ";
                                                        exit ;
                                                        }
                                                        if ($Start_Hour <= $End_Hour) {
                                                        print "This is Right Order Of Time Duration"."\n" ;
                                                        }
                                                        else {
                                                        print "End_Hour should be greater than or equal to start hour. Give the right ordering" ;
                                                        exit ;
                                                        }
                                                        if ($End_Hour == 24){
                                                        print "Default Value of End Minute when End Hour is 24"."\n" ;
                                                        $End_Min = 00 ;
                                                        print $End_Min."\n";
                                                        }
                                                        print "Give THe File Name To wirte the Logs-->"."\n";
                                                        chomp($output_file = <STDIN>);
                                                        print "Output File Name is --> ".$output_file."\n";
                                                        #print "Give Category you want to analyze ";
                                                        #chomp($Category = <STDIN>);
                                                        #print " Category Choosen --> ".$Category."\n";
                                                        &break_component ;
                                                        &hourly_op ;
                        } elsif ($ARGV[1] =~ "--All3Ip") {
                                                        &break_component;
                                                        &new_all3_ip ;
                        }
                          elsif ($ARGV[1] =~ "--URL") {
                                                        &break_component;
                                                        &uniqe_url;
                                                        &greedy_parse;
                                                        &parse_unique;
                        }  elsif ($ARGV[1] =~ "--HperIP") {
                                                        &break_component;
                                                        &perIPhit;
                        }

        ############### parsing of command line argument over ############