Toolchains have a loose name convention like
|
Toolchains have a loose name convention like
|
/*Merge sort is a divide and conquer sorting technique in which we divide big problems into small i.e. in this we divide a big array into small arrays and after sorting these arrays we merge it and after merging it we get a sorted array.
At the time of doing this sorting technique i find some of the problems like garbage values and also segmentation faults so i tried to do this technique with a small array than after sometime i get my result*/
#include
void mergesort(int *,int ,int );
void merge(int *,int,int,int);
#define max 50
int main()
{
int merge[max],n,i,p=0;
printf(“enter no. of elements that you want to sort\n”);
scanf(“%d”,&n);
printf(“enter the elemrnts of array\n”);
for(i=0;i<n;i++)
scanf("%d",&merge[i]);
mergesort(merge, p, n-1);
printf("\n");
for(i=0;i<n;i++)
{
printf("a[%d]=%d\n",i,merge[i]);
}
return 0;
}
void mergesort(int* a,int p,int r)
{
int q;
if(p<r)
{
q=(p+r)/2;
mergesort(a,p,q);
mergesort(a,q+1,r);
merge(a,p,q,r);
}
}
void merge(int* a,int p,int q,int r)
{
int i=p,l=p,m=q+1,temp[max],k;
while(l<=q&&ma[m])
{
temp[i]=a[m];
m++;
}
else
{
temp[i]=a[l];
l++;
}
i++;
}
if(l>q)
{
for(i=i;iq temp[%d]=%d,a[%d]=%d\n”,i,temp[i],m,a[m]);
}
}
else
{
for(i=i;ir temp[%d]=%d,a[%d]=%d\n”,i,temp[i],l,a[l]);
}
}
for(i=p;i<=r;i++)
{
a[i]=temp[i];
printf("temp[%d]=%d,a[%d]=%d\n",i,temp[i],i,a[i]);
}
}
CD – Change Directory Command
=============================
- cd means change working directory
- Prototype:
cd [-L | -P] [directory]
cd -
-If you do not give any directory to cd command, it will take you to home directory.
eg. cd –> It will go to home directory.
- For previous directory use :
cd ..
- Further for more than one previous directory use :
cd ../..
- Directory can be defined by 2 types :
i) Absolute filepath – Path starting from ‘/’.
eg. cd /usr/bin/
ii)Relative Filepath – Path relative to current directory
eg. cd /usr –> Absolute filepath
cd etc –> Relative Filepath
Common Linux Virtual Directories
=================================
Directory Usage
/ Root of virtual directory. No files are placed here (normally)
/bin Binary directory.GNU user level utilities are stored
/boot Boot directory.Boot files are stored here
/dev device directory, where linux creates device nodes
/etc system configuration files directory
/home home directory, user directories are placed here
/lib System & application library files are stored here
/media Common place for mount point of removable media
/mnt mount directory, for removable devices
/opt used to store optional software packages
/root home directory of root user
/sbin GNU admin level utilities are store here
/tmp Temporary work files are created and destroyed
/usr User installed softwares directory
/var For frequently changing directory ,such as log files
Linux Filesystem
================
- In windows, physical drive determines the pathname of the file.
- Windows assigns a letter to each disk drive.
- Each directory contains its own directory structure for accesing files stored in it.
- For eg. in windows filepath is as:
c:\Users\ankur\Documents\Lessons.doc
- Linux does not use drive letters in pathnames like windows.
- Linux stores files within a single directory structure, called a virtual directory.
- Virtual directory contains filepaths from all storage devices installed on PC, mergedinto a single directory.
- There is a single base directory, called the root.
- root drive contains core of virtual directory.
- On root drive, Linux has special directories called mount points.
-When we start a new shell prompt, your session starts in your home directory.
To get help in fedora
=====================
To learn about any new command, function or utility in Fedora we can get help from it.
It has 3 such commands :-
i) man pages – These are manual pages .
- It contains interface to online reference manuals
- Press q to exit.
- How to Use ( Command ) – man command_name
- for all man pages of BASH shell, use
man bash
- It generally contains following information about command(command_name) :-
* Name
* Synopsis (Prototype)
* Description (Options)
* Author (author of command)
* Reporting Bugs (Feedback emails/Website)
* Copyright (copyright details)
* See Also (for further reference of command)
ii) Info pages – Read info documents
- It contains BASH manuals.
- Press q to exit
- How to Use (command) – info command_name
- It contains information about :-
* Prototype
* Introduction
* Options
* Exit Status
iii) help command
- It gives basic help for using a command and its various options.
- It gives output on Standard Output.
- It do not require exit command.
- How to Use (command) – help command_name
- It contains following information about command (command_name) :-
* Function of command
* Options
* Exit status
eg.
man echo
info echo
help echo
- To check total no. of enteries in each of three
I) type either of three (with space at end)
II) Press tab button for 3-4 times.
We will get the total number of possible options defined or list of them also.
eg. (<tab> means Press tab button)
man <tab><tab><tab>
#include<stdio.h>
int main()
{
int a=5;
int b=6;
int c=7;
a^=b,b^=a,a^=b;
b^=c,c^=b,b^=c;
printf(“a= %d\n”,a);
printf(“b= %d\n”,b);
printf(“c= %d\n”,c);
return 0;
}
RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
In file include a all header files realted this project.
—————————-
revision 1.1
date: 2016/02/04 11:32:41; author: root; state: Exp;
Initial revision
=============================================================================
RCS file: request.h,v
Working file: request.h
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
In file delacare a structure name is struct opreations and decalre a in member variable .
—————————-
revision 1.3
date: 2016/02/04 20:20:28; author: root; state: Exp; lines: +0 -1
In file decalre result varable.
—————————-
revision 1.2
date: 2016/02/04 20:19:24; author: root; state: Exp; lines: +1 -0
*** empty log message ***
—————————-
revision 1.1
date: 2016/02/04 11:33:11; author: root; state: Exp;
Initial revision
=============================================================================
RCS file: processing_client.c,v
Working file: processing_client.c
head: 1.8
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8; selected revisions: 8
description:
In file a getv the all structure data read the all structure using pipe and then found the result give the sever call to to the write.
—————————-
revision 1.8
date: 2016/02/07 11:01:05; author: root; state: Exp; lines: +2 -0
In file removes the all sleeps.
—————————-
revision 1.7
date: 2016/02/04 19:16:31; author: root; state: Exp; lines: +1 -1
In file display a operator.
—————————-
revision 1.6
date: 2016/02/04 19:14:40; author: root; state: Exp; lines: +1 -1
In file some changing.
—————————-
revision 1.5
date: 2016/02/04 19:12:48; author: root; state: Exp; lines: +4 -1
In file get a display structure in member variable.
—————————-
revision 1.4
date: 2016/02/04 19:07:15; author: root; state: Exp; lines: +1 -0
In file calling sleep in 2 sec.
—————————-
revision 1.3
date: 2016/02/04 19:05:20; author: root; state: Exp; lines: +1 -1
In file now write a result.
—————————-
revision 1.2
date: 2016/02/04 18:50:16; author: root; state: Exp; lines: +1 -0
In file wfd,rfd and result are variables declare.
—————————-
revision 1.1
date: 2016/02/04 13:33:06; author: root; state: Exp;
Initial revision
=============================================================================
RCS file: request_client.c,v
Working file: request_client.c
head: 1.8
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 8; selected revisions: 8
description:
In file declare a struct operations type a variable and all sturcture members in values all assign .
then call to the open and file open the all structure write a in fifo then call to the sleep in 5 sec.
—————————-
revision 1.8
date: 2016/02/07 11:01:44; author: root; state: Exp; lines: +1 -1
In file check the this file write the data or not.
—————————-
revision 1.7
date: 2016/02/04 20:20:54; author: root; state: Exp; lines: +1 -1
In file declare a result varibale and display the result .
—————————-
revision 1.6
date: 2016/02/04 20:19:26; author: root; state: Exp; lines: +7 -9
*** empty log message ***
—————————-
revision 1.5
date: 2016/02/04 20:02:32; author: root; state: Exp; lines: +20 -2
In file get a result of the server and display the result and add a if else condition in a file.
—————————-
revision 1.4
date: 2016/02/04 12:05:34; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2016/02/04 11:49:47; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2016/02/04 11:48:32; author: root; state: Exp; lines: +14 -1
In file add a some checking condtions.
—————————-
revision 1.1
date: 2016/02/04 11:34:07; author: root; state: Exp;
Initial revision
=============================================================================
RCS file: server.c,v
Working file: server.c
head: 1.11
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 11; selected revisions: 11
description:
In file a first one declare a struct operations type a variable then calling to the system call is access and in condtions the fifo file in already avialable or not check the access then if not available the fifo file then call to mkfifo the n create fifo file and then call the open if open file is successfully then call to the read and read the structure in a fifo then all the structure is display in which some condions.
—————————-
revision 1.11
date: 2016/02/07 11:02:37; author: root; state: Exp; lines: +1 -3
In file removes the all sleep.
/.
—————————-
revision 1.10
date: 2016/02/04 20:05:33; author: root; state: Exp; lines: +15 -0
In file get a result to proceesing client and then in sleep 3 sec then give the result of the request client .
—————————-
revision 1.9
date: 2016/02/04 19:16:56; author: root; state: Exp; lines: +1 -1
In file read a result .
—————————-
revision 1.8
date: 2016/02/04 18:55:15; author: root; state: Exp; lines: +3 -3
In file check the working .
—————————-
revision 1.7
date: 2016/02/04 18:51:20; author: root; state: Exp; lines: +2 -0
In file get result to processing client and display a result in file.
—————————-
revision 1.6
date: 2016/02/04 13:34:28; author: root; state: Exp; lines: +25 -5
In file call a first call to the pipe and create a pipe then call to fork and then add a switch statements then execl call and and write a data give the all structure to processing client and then get a result of the processing client .
—————————-
revision 1.5
date: 2016/02/04 12:05:36; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2016/02/04 11:53:18; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.3
date: 2016/02/04 11:52:22; author: root; state: Exp; lines: +1 -1
*** empty log message ***
—————————-
revision 1.2
date: 2016/02/04 11:43:54; author: root; state: Exp; lines: +2 -0
*** empty log message ***
—————————-
revision 1.1
date: 2016/02/04 11:36:18; author: root; state: Exp;
Initial revision
=============================================================================
SHELL SCRIPT
#! /bin/bash
delete()
{
rm -rf server
rm -rf request_client
}
edit()
{
read -p “do you want a edit further (y or n)” answer
if [ 'y' = $answer ]
then
for file in $(ls *.h,v)
do
co -l $file
done
for file in $(ls *.c,v)
do
co -l $file
done
delete
exit 0
fi
}
execute()
{
read -p “do you want a execute script(y or n)” answer
if [ 'y' = $answer ]
then
if (gcc -o server server.c)
then
echo “compailation successfully”
else
echo “compailation is failed”
edit
fi
if (gcc -o request_client request_client.c)
then
echo “compailation successfully”
else
echo “compailation is failed”
edit
fi
if (gcc -o processing_client processing_client.c)
then
echo “compailation successfully”
else
echo “compailation is failed”
edit
fi
else
edit
fi
./server & ./request_client
}
logfile()
{
chmod +x rlog.sh
./rlog.sh
edit
}
for file in $(ls *.h)
do
ci $file
done
for file in $(ls *.c)
do
ci $file
done
for file in $(ls *.h,v)
do
co $file
done
for file in $(ls *.c,v)
do
co $file
done
execute
read
logfile
To change default prompt :-
========================
- We can change default prompt by assigning the character to it.
- Each character have a specific meaning.
BASH Shell Prompt Characters :-
Character Description
\a Bell Character
\d Date in format “Day Month Date”
\e ASCII escape character
\h Local hostname
\H Fully qualified domain hostname
\j Number of jobs currently managed by the shell
\l Basename of the shell’s terminal device name
\n ASCII newline character
\r ASCII carriage return
\s Name of the shell
\t Current time in 24-hour HH:MM:SS format
\T Current time in 12-hour HH:MM:SS format
\@ Current time in 12-hour am/pm format
\u Username of current user
\v Version of BASH shell
\V Release level of bash shell
\w Current working directory
\W Basename of current working directory
\# Command number of this command
\$ A dollar sign if normal user, #(Pound) for root user
/nnn Character corresponding to value nnn
\\ Backslash
\[ Begins a control code sequence
/] Ends a control code sequence
eg.
[ankur@(none) ~]$ PS1 = “[\t][\u]$”
[15:20:30][ankur]$
Command line Prompt
===================
Environmental variables that controls Command line Prompt
PS1 : Controls the format of default command line prompt.
PS2 : Controls the format of second-tier command line prompt.
PS3 : Controls the format of tertiary command line prompt.
- Shell uses default PS1 prompt for initial data entry into shell.
- If we enter a command that requires additional information, shell displays second-tier prompt specified by PS2 .
- To display current settings for prompt use command :
echo $PS1
echo $PS2
- PS3 is used only in shell scripts.
RCS file: fork.c,v
Working file: fork.c
head: 1.1
branch:
locks: strict
reena: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1; selected revisions: 1
description:
process duplication for project 03: Inter Process Communication
using fork()
—————————-
revision 1.1 locked by: reena;
date: 2016/02/07 12:58:41; author: reena; state: Exp;
Initial revision
=============================================================================