Beruflich Dokumente
Kultur Dokumente
Unit 1
General overview of the system
Benefits of Unix
System Structure
The unix system can be viewed as the set of layers. The lowermost
layer is the hardware layer which is not the part of the unix operating
system. The operating system is called the system kernel or the
kernel.
Kernel is the layer where the actual operating system code and
functionality resides. It is in complete isolation from the user
programs.
If a user program want to perform any task it can do so by talking to
the kernel. The programs interact with the kernel by using the system
calls. The system calls instruct the kernel to do various operations.
Other user programs can be built on top of the lower level programs
using these lower level programs and system calls .
BY : MANISH ROHILA 2015
A hierarchal structure.
Consistent treatment of data
Ability to create and delete files
Dynamic growth of files
Peripheral devices are also treated as files
The file system is organized as a tree. The root node is called “root”
and is denoted by “/”. Every non leaf node in this structure is a
directory and every leaf node is a file/special device file.
User level
Kernel level
Processes in user mode can access their own instructions but not the
kernel instructions or the instruction of other processes. On the other
hand processes in kernel mode can access kernel data and instructions
as well as user data and instructions.
Introduction to kernel
This inode is short form for index node. Every file has one inode. The
inodes of all the files on the system are stored in inode table. When we
create a new file a new entry in the inode table is created.
The kernel contain two data structures file table and user file
descriptor table. The file table is global table at the kernel level but the
user file descriptor table s for every process. When a process creates a
file or opens a file the entry for that is made in both the tables.
The information about the current state of the file is maintained in the
file table. For example if the file is being written the information about
the current cursor position is kept in the file table. This file table also
checks whether the accessing process has access to that file or not.
The user file descriptor table keeps a track of all the files opened by
the processes and what are the relationships between these files.
The regular files and folders are kept on block devices like disks and
tape drives. The drive has logical block numbers and physical block
numbers and the mapping from logical to physical block numbers is
done by disk driver.
BY : MANISH ROHILA 2015
The boot block occupies the beginning of the file system. This
contains the bootstrap code that is required for the machine to
boot.
Super block describes the state of the file system i.e. its size,
maximum number of files that can be stored and the free space
information.
The inode list contains the inode table and the kernel references
the inode list area to get the information about the files stored
on the machine.
The data block is the end of the inode list and starting of the
blocks that can be used to store the user files. The starting area
of the data block will contain some administrative files and
information and the later block contains the actual files.
The kernel data structures occupy fix size tables rather than
dynamically allocated space. This approach has one advantage, the
kernel code is simpler but there is one disadvantage of this approach
BY : MANISH ROHILA 2015
System Administration
we know that the files are stored on the hard drive and the processes
can access these files and create new files on the disk. When a process
requests for a file the kernel brings the file into the main memory
where user process can change, read or access the file.
The kernel could read and write the file directly from the hard disk and
put it in memory and vice versa but the response time and throughput
will be very low in this case because of disks slow data transfer speed.
When the process want to read a file the kernel attempts to read this
file in the buffer cache, if the data is found in the buffer cache the
data/file is sent to the process. If the file is not found in the buffer
cache then the file is read from the disk and then kept in the buffer
cache so that it can be made available to the process.
To minimize the disk access frequency the kernel may also implement
the pre-caching or write delay functionalities.
Buffer Headers
When the system initializes the kernel allocates the space for the
buffer cache. The buffer cache contains two regions/arts. One for the
data/files that will be read from the disk, second the buffer header.
BY : MANISH ROHILA 2015
There will never be a case when the buffer has two entries for the
same file on disk as this could lead to inconsistencies. There is only
only one copy of a file in the buffer.
The kernel caches the least recently used data into the buffer pool.
Once a block from buffer pool is allocated for a file of the system this
block cannot be used for any other file’s data. The kernel also
maintains a free list of buffers. The free list is a doubly circular list of
buffers.
When kernel wants to allocate any buffer it removes a node from the
free list, usually from the beginning of list but is could take it from
middle of the list too. When kernel frees a node from the buffer list it
adds this free node at the end of the free list.
BY : MANISH ROHILA 2015
The five typical scenarios that kernel may follow in getblk to allocate a
buffer in the disk block are
The first scenario - Block in the hash queue, and its buffer is free.
BY : MANISH ROHILA 2015
The second scenario - Cannot find block on the hash queue =>
allocate a buffer from free list.
BY : MANISH ROHILA 2015
The third scenario - Cannot find block on the hash queue =>
allocate a buffer from free list but buffer on the free list marked
“delayed write” => flush “delayed write” buffer and allocate another
buffer.
The fourth scenario - Cannot find block on the hash queue and free
BY : MANISH ROHILA 2015
The kernel may read the data, manipulate it and/or change it in the
buffer. While the kernel marks the buffer as busy so that no other
process can access this block. When the kernel is done using this block
it releases the buffer using brelse algorithm.
Unit -2
Inodes
Consist of:
• File owner identifier (individual owner & group owner)
• File type (regular, directory, character or block special, or FIFO – pipes)
• File access permissions (owner, group, other: read, write, execute)
• File access time
• Number of links to the file
• Table of contents for the disk addresses of data in a file
• File size
Algorithm for allocation of in-core inodes
algorithm iget
input: file system inode number
output: locked inode
{
while (not done)
{
if (inode in inode cache)
{
if (inode locked)
{
sleep (event inode becomes unlocked);
continue; /*loop back to while */
}
/*special processing for mount points */
if (inode on inode free list)
remove from free list;
increment inode reference count;
return (inode);
}/
*inode not in inode cache */
if (no inodes on free list)
BY : MANISH ROHILA 2015
return (error);
remove new inode from free list;
reset inode number and file system;
remove inode from old hash queue, place on new one;
read inode from disk (algorithm bread);
initialise inode (e.g. reference count to 1);
return (inode);}
Directories
• Give the file system its hierarchical structure
• Important role in conversion of a file name to an inode number
• Initial access: open, chdir, link system calls
• Algorithm namei uses intermediate indoes as it parses a path name
Super block
Consists of:
• The size of the file system
BY : MANISH ROHILA 2015
File System
Calls
Retur Use of Assig File File File Tree
nfile namei n Attribute I/O Sys Manipulati
desc inode s Structu on
open open stat creat
decs s re
creat creat link mkno chown read
File mount chdir
dup chdir unlink d chmod write
Desc umount chown
pipe chroot mkno link stat lseek
close chow d unlin
n mount k
chmo umou Lower Level File System Algorithms
d nt
namei Ialloc
alloc free bmap
iget iput ifree
open
Syntax
fd = open(pathname, flags, modes);
pathname: file name
flags : type of open
modes : file permission if file is being created
fd : File Descriptor
{
convert file name to inode(algorithm namei);
if(file does not exist or not permitted access)
return (error);
allocate file table entry for inode, initialize count, offset;
allocate user file descriptor entry, set pointer to file table entry;
if(type of open specifies truncate file)
free all file blocks (algorithm free);
unlock(inode) /* locked above in namei */
BY : MANISH ROHILA 2015
Read
number = read(fd, buffer, count)
fd : file descriptor returned by open
buffer : address of structure in the user process that will contain the
read data
count : number of bytes the user wants to read
number : number of bytes actually read
{
get file table entry from user file descriptor;
check file accessibility;
set parameters in u area for user address, byte count, I/O to user;
get inode from file table;
lock inode;
set byte offset in u area from file table offset
while(count not satisfied) {
convert file offset to disk block (algorithm bmap);
calculate offset into block, number of bytes to read;
if(number of bytes to read is 0)
/* trying to read end of file */
read block(algorithm breada if with read-ahead, algorithm bread
otherwise);
copy data from system buffer to user address;
update u area fields for byte offset,read count,address to write into user
space;
release buffer; /* locked in bread */
}
unlock inode;
update file table offset for next read;
return(total number of bytes read);
file creation
Goal
Create a New File
Syntax
fd = creat(pathname, modes);
Function
If File does not exist
kernel create new file with specified name and permission mode
If File exists
BY : MANISH ROHILA 2015
truncates the file( release all existing data blocks and sets the file
size to 0 ) subject to suitable file access permissions.
Goal
creates special files
named pipes
device files
directories
Syntax
mknod(pathname, type and permissions, dev)
pathname: name of the node to be created
type and permissions : node type and access permission
dev: specifies the major and minor device numbers for block and
character special files
Function
allocates inode for the file
Algorithm
if(new node not named pipe and user not super user)
return(error);
get inode of parent of new node ( algorithm namei );
if(new node already exists)
{
BY : MANISH ROHILA 2015
assign free inode from file system for new node (algorithm ialloc);
create new directory entry in parent directory
: include new node name and newly asigned inode nubmer;
release parent directory inode (algorithm iput);
change directory
Goal
Change the current directory of a process
Syntax
chdir(pathname);
pathname : directory that becomes the new current direcotry of the
process
Algorithm
change root
Goal
Change the notion of the file system root
Syntax
chroot(pathname);
pathname: Directory that the kernel subsequently treats as the
process’s root directory.
Algorithm
get inode for new directory name (algorithm namei);
if(inode not that of directory or process not permitted access to file)
{
BY : MANISH ROHILA 2015
Named pipes are used when the process are not closely related wants to communicate .
A named pipe is accessed by its pathname . the processes can use a named pipe either
for reading or writing .a process open a named pipe like a file . An unnamed pipe can
only be used by closely related process .
The systax for creation of pipe is –
Pipe(fdptr);
Where fdptr is pointer to integer array that will contain the two file descriptor for reading
and writing the pipe.
Algorithm
Algo : pipe
Input : none
Output: read file descriptor ,write file descriptor
{
Assign new inode from pipe device(algo ialloc);
Allocate the table entry for reading,another for writing ;
Initialize file table entries to point to new inode;
Allocate user dile descriptor for reading,another for writing,initialize to point to
respective file table entries;
set node reference count to 2;
initialize count of inode readers,writers to 1;
}
Where special pathname is the name of device special file of the disk section containing
the file system to be mounted,directory pathname is the directory in the existing
hierarchy where the file system will be mounted and option indicate whether the file
system should be mounted “read only”.
Algorithem
Algo: mount
Inputs:file name of block special file,directory name of mount point,options(read only)
Output:none
{
If(not super user)
Return(error);
Get inode for block spcial file(algo namei);
Make legality checks:
Get inode for ”mounted on” directory name(algo namei);
If(not directory,or reference count>1)
{
Release inodes (algo iput);
Return(error);
}
Find empty slot in mount table;
Invoke block device open routine;
Get free buffer from buffer cache;
Read super block into free buffer;
Initialize super block fields;
Get root inode of mounted device(algo iget)
Save in ount table;
Mark inode of “mounted on” directory as mount point;
Realese special file inode(algo iput);
Unlock inode of mount point directory;
}
BY : MANISH ROHILA 2015
Unit 3
6. The process is sleeping , and the swapper has swapped the process to secondary storage to
make room for other processes in main memory .
7. The process is returning from the kernel to user mode, but the kernel preempts it and does
a context switch to schedule another process.
8. The process is newly created and is in a transition state; the process exists, but it is not
ready to run, nor is it sleeping .This state is the start state for all processes except process 0.
9. The process executed the exit system call and is in the zombie state, the process no longer
exists, but it leaves a record containing an exit code and some timing statistics for its parent
process.
BY : MANISH ROHILA 2015
Assume that the physical memory of machine is addressable, starting at byte offset 0 and
going up to a byte offset equal to amount of memory on the machine.
A process on the unix system consists of three logical sections: text, data and stack.
The text section contains the set of instructions the machine executes for the process;
o address in the text section includes.
o text addresses (for branch instructions or subroutines calls)
o data addresses (for access to global data variables) or
o stack addresses (for access to data structures local to subroutines).
If the machine were to treat the generated addresses as address location in physical memory,
o it would be impossible for two processes to execute concurrently if their set of generated
addresses overlapped .
The compiler could generate addresses that did not overlap between programs that is
impractical for general purpose computer because the amount of memory on a machine is
finite and the set of all programs that could be compiled is infinite.
If compiler used heuristics to try to avoid unnecessary overlap of the generated addresses, the
implementation would be inflexible and therefore undesirable.
The compiler therefore generates addresses for a virtual addresses space with a given address
range, and the machines memory management unit translates the virtual addresses generated
by the compiler in to address location in the physical memory.
o the compiler does not have to know where in memory the kernel will later load the
program for execution.
o several copies of a program can coexists in memory:
o all executes using the virtual addresses but reference different physical addresses
The Context of a Process:
The context of a process consists of the contents of its (user) address space and the contents
of hardware registers and kernel data structure that relate to the process.
Formally, the context of a process is the union of its user-level context, register context, and
system-level context.
The user-level context consists of the process text, data, user stack and shared memory that
occupy the virtual address space of the process.
o Parts of the virtual address space of a process that periodically do not reside in main
memory because of swapping or paging still constitute a part of the user-level context.
The register context consists of the following components:
o The program counter specifies the address of the next instruction the CPU will execute;
the address is a virtual address in kernel or in user memory space.
o The processor status register (PS) specifies the hardware status of the machine as it relates
to the process.
For e.g. the PS usually contains subfields to indicate that the result of a recent
computation resulted in a zero, positive, or negative result or that a register overflowed, and a
carry bit is set.
Other subfields indicate, the current processor execution level (for interrupts) and the current
and most recent modes of execution (such as kernel, user).
Most recent modes determine whether a process can execute privileged instructions and
whether it can access kernel address space.
BY : MANISH ROHILA 2015
o The stack pointer (SP) contains the current address of the next entry in the kernel or user
stack, determined by the mode of execution.
Machine architectures dictate whether the stack pointer points to the next free entry on the
stack or to the last used entry.
o The general-purpose registers contain data generated by the process during its execution.
The system-level context of a process has a “static part” and a “dynamic part”.
o A process has one static part of the system-level context throughout its life time but it can
have a variable number of dynamic parts.
o The dynamic part of the system-level context should be viewed as a stack of context layers
that the kernel pushes and pops on occurrence of various events.
The system-level context consists of the following components:
o The process table entry of a process defines the state of a process and contains control
information i.e. always accessible to the kernel.
o The u area of a process contains process control information that need be accessed only in
the context of a process.
General parameters such as process priority are stored in the process table because they
must be accessed outside the process context.
o Pregion entries, region tables and page tables, define the mapping from virtual to physical
addresses and therefore define text, data, stack and other regions of a process.
If several processes share common regions, the regions are considered part of the context
of each process, because each process manipulates region independently.
o The kernel stack contains the stack frames of kernel procedures as a process executes in
kernel mode.
All processes execute the identical kernel code, but each process has its own private copy
of the kernel stack – these specify their particular invocation of kernel function.
For e.g. one process may invoke the creat system call, and go to sleep waiting for the
kernel to assign a new inode, and another process may invoke read system call and go to
sleep awaiting the transfer of data from disk to memory.
Both processes execute the kernel functions, but they have separate stacks that contain their
private function call sequence.
The kernel must be able to recover the contents of the kernel stack and position of the
stack pointer to resume execution of a process in kernel mode.
System implementation frequently places the kernel stack in the process u area, but it is
logically independent and can exist in an independently allocated area of memory.
The kernel stack is empty when the process executes in user mode.
o The dynamic part of the system-level context of a process consists of a set of layers,
visualized as a last-in-first-out stack.
Each system-level context layer contains the necessary information to recover the
previous layer, including the register context of the previous level.
The kernel pushes a context layer when an interrupt occurs, when a process makes a system
call, or when a process does a context switch.
It pops a context layer when the kernel returns from handling an interrupt, when a process
returns to user mode after the kernel completes the execution of a system call, or when a
process does a context switch.
The context switch thus entails a push or a pop of a system-level context layer:
o The kernel pushes the context layer of the old process and pops the context layer of the
new process.
BY : MANISH ROHILA 2015
o The process table entry stores the necessary information to recover the current context
layer.
Process Creation
The only way for a user to create a new process in the Unix OS is to invoke the fork system
call.
The process that invokes fork is called the parent process and the newly created process is
called the child process.
The syntax for the fork system call is
pid=fork( );
BY : MANISH ROHILA 2015
Process Termination
Processes on a UNIX system terminate by executing the exit system call.
An existing process enters the zombie state, relinquishes its resources, and dismantles its
context except for its slot in the process table.
The syntax for the call is
exit (status);
where the value of status is returned to the parent process for its
examination.
The real user id identifies the user who is responsible for the running process.
The effective user id is used to assogn ownership of newely created files,to chek
file access permission and to chek permission to send signals to processes via
the kill system call.thekernel allows a process to change its effective user id
when it execs a setuid program or when it invokes the setuid system call
explicitly.
Setuid(uid)
BY : MANISH ROHILA 2015
In which uid is the new user id and its result depends on the current value of the
effiective user id.
A process may increase or decrease the size of its data region by using the brk
system call. Systax is
Brk(endds);
In which ends becomes the value of the hightest virtual adderess of the data region of
the process.if the process is calling brk to free previously allocated space,the kernel
release the memory.if the process virtual address in pages which it had releated.it
incurs a memory fault.
Algo :brk
Return(error);
THE SHELL:
The shell read a command line from its standard input and interprets it according to a
fixed set of rules.the standard input and standard output. File descriptors for the login
shell are usually the terminal on which the user logged in.if the shell recognize the input
BY : MANISH ROHILA 2015
string as a built in command it executes the command internally without creating new
process;otherwise it assumes the command is the name of an excuting file.
SYSTEM V IPC:
The unix system V IPC package consists of three mechanisms.
Message allow process to send formatted data stream to arbitary processes,shared
memory allows prosesses to share parts of their virtual address space and
semaphores allows process to syschronize execution.implemented as a unit,they
share common properties.
each mechanism contain a table whose entries describe all instance of the
mechanism.
Each entry contain a numeric key,which is its user chosen name.
Each meachanism contain a “get” system call to create a new entry or to
retrieve an existing one,and the parameters to the calls include a key and
flages.the kernel search the proper table for an entry amed by the key.
For each IPC meachinsm the kernel uses the follwing formula to find the
index into the table of data structures from the descriptor:
index =descriptor modulo(number of entries in table)
Each IPC entry has a permission structure that includes the user ID and
group ID of the process.
Each entry contain other statuss information,such as the process ID of the
last process to update the entry.
Each mechanism contain a “control” system call to query status of an entry
to set status information or to remove the entry from the system.
NETWORK COMMUNICATION
Program such as mail,remote file transfer,and remote login that wish
to communicate with other machines have historically used ad hoc methods to
establish connection and to exchange data.when a person send mail to another user
on the same machine, the mail program appends the mail to addresses file,using
lock files and temporary files to preserve consistency.when a person read mail,the
mail program open the persons mail file and read the message.to send mail to a user
on another machine the mail program must ultimately find appropriate mail file on
the other machine.since it cannot manipulate files there directly a process on the
other machine must act as a agent for the local mail process hence the localprocess
needs way to communicate with it remote agent across machine boundaries.
BY : MANISH ROHILA 2015
The unix system creates new processes via the fork system call the server
process must exist before the client process attempt to establish a connection.it
would be inconsistent with design of the system if the remote kernel were to create a
new process when a connection request come across the network.client and server
program typically choose the network media and protocols according to information
in application data bases or the data may be hard coded into the programs.
SOCKETS
The methods by which they establish communication are likely to difer
depending on protocols and media.the methods may not allow processes to
communicate with otherprocesses on the same machine because they assume the
existence of a server process that sleeps in a driver open or read system call.to
provide common method for interprocess communication and to allow use to
sophisticated network protocol the BSD system provides a mechanism known as
sokets.
The Kernel structure consists of three parts:the soket layer,the protocol layer,and
the device layer. The socket layer provides the interface between system calls and
lower layers,the protocol layer contain the protocol modules used for
communication and thedevice layer contain the device drivers that control the
network device. The socket system call establishes the end point of a communication
link.
Sd=socket(format,type,protocol);
Format specifies the communication domain ,type indicate the type of
communication over the socket and protocol indicates a particular protocol to
control the communication.processes use the socket descriptor sd in other system
calls.
BY : MANISH ROHILA 2015
MULTIPROCESSOR SYSTEM:
A multiprocessor architecture contain two or more cpu
that share common memory and peripherals,potentially providing greater system
throughput,since processes can run concurrently on different processors.each cpu
excutes independently but all of them excute one copy of the kernel.processes
behave exactly as they would on a uniprocess or system-the semantics of each
system call remain the same but they can migrate between processsors
transparently.some multiprocessor system are called attached processor system.
Unit 4
INTRODUCTION
Index of Commands
cat - display or concatenate files
cd - change directory
chmod - change the permissions on a file or
directory
compress - compress a file
cp - copy a file
date - display the current date and time
diff - display differences between text files
echo - echo arguments to the standard output
file - determine the type of a file
find - find files of a specified name or type
finger - display information about a user
ftp - file transfer program
grep - searches files for a specified string or
expression
kill - kill a process
lpr - print out a file
ls - list names of files in a directory
man - display an on-line manual page
mkdir - make a directory
more - scan through a text file page by page
mv - move or rename files or directories
nice - change the priority at which a job is being
run
passwd - change your password
ps - list processes
pwd - display the name of your current directory
quota - disk quota and usage
rm - remove files or directories
rmdir - remove a directory
sort - sort and collate lines
talk - talk to another user
BY : MANISH ROHILA 2015
• VARIABLES
Name Meaning
- the syntax for assigning a variable in the Bourne, Bash and Korn
shells is as follows:
BY : MANISH ROHILA 2015
METACHARACTERS
Symbol Meaning
do
commands ...
done
Example:
for file in ex1.c ex2.c yesno.c
do
echo "==== $file ===="
cat $file
done
Unix Shells
! Conditional Expressions
! IF Statement
if test-command
then
commands ... # when status is zero
else
commands ... # when status is non-zero
fi
Example:
if cp yourfile myfile
then
vi myfile
fi
This executes the command "cp yourfile myfile". If it is successful (i.e. the copy
worked), then it will edit myfile
! WHILE Statement
while test-command
do
commands...
done
! BREAK & CONTINUE Statements
break transfers control to statement after the done where as continue transfers
control to the done, and the loop
continues execution.
Unix Shells
! CASE Statement
case test-string in
pattern-1)
commands
;;
pattern-2)
commands
;;
:
BY : MANISH ROHILA 2015
Esac
Unit 5
Awk pattern scanning and processing language:
1 ability to view a text files as made up of records and fields on a textual database.
6 Define function.
Awk statements are usually applied to all lines selected by the address and if there are
no address they are applied to every line of input.if we like to print something before
processing the first line,then the BEGIN section can be used.similarly the END section
is useful in printing some calculation after the processing is completed.
BEGIN
{action}
END
BY : MANISH ROHILA 2015
{action}
OPERATORS
Symbol Meaning
= += -= *= /= %= ^= **= Assignment
?: C conditional expression (nawk only)
|| Logical OR (short-circuit)
&& Logical AND (short-circuit)
in Array membership (nawk only)
~ !~ Match regular expression and negation
< <= > >= != == Relational operators
(blank) Concatenation
+ - Addition, subtraction
* / % Multiplication, division, and modulus (remainder)
+ - ! Unary plus and minus, and logical negation
^ ** Exponentiation
BY : MANISH ROHILA 2015
Symbol Meaning
++ -- Increment and decrement, either prefix or postfix
$ Field reference
BUILT IN FUNCTION
index
index(str, substr)
Return the position (starting at 1) of substr in str, or zero if substr is not present in str.
int
int(x)
length
length([arg])
log
log(x)
rand
rand()
Generate a random number between 0 and 1. This function returns the same series of
numbers each time the script is executed, unless the random number generator is seeded
using srand(). {N}
return
BY : MANISH ROHILA 2015
return [expr]
Used within a user-defined function to exit the function, returning value of expr. The
return value of a function is undefined if expr is not provided. {N}
sin
sin(x)
split
split(string, array [, sep])
Split string into elements of array array[1],...,array[n]. The string is split at each
occurrence of separator sep. If sep is not specified, FS is used. The number of array
elements created is returned.
sprintf
sprintf(format [, expressions])
Return the formatted value of one or more expressions, using the specified format (see
printf). Data is formatted but not printed. {N}
sqrt
sqrt(arg)
srand
srand([expr])
Use optional expr to set a new seed for the random number generator. Default is the time
of day. Return value is the old seed. {N
sub
sub(r, s [, t])
Substitute s for first match of the regular expression r in the string t. If t is not supplied,
defaults to $0. Return 1 if successful; 0 otherwise. {N}
BY : MANISH ROHILA 2015
substr
substr(string, beg [, len])
Return substring of string at beginning position beg and the characters that follow to
maximum specified length len. If no length is given, use the rest of the string.
system
system(command)
Function that executes the specified command and returns its status. The status of the
executed command typically indicates success or failure. A value of 0 means that the
command executed successfully. A nonzero value indicates a failure of some sort. The
documentation for the command you're running will give you the details.
The output of the command is not available for processing within the awk script. Use
command | getline to read the output of a command into the script. {N}
systime
systime()
Return a time-of-day value in seconds since midnight, January 1, 1970, UTC. {G}
tolower
tolower(str)
Translate all uppercase characters in str to lowercase and return the new string.[6] {N}
toupper
toupper(str)
Translate all lowercase characters in str to uppercase and return the new string. {N}
if
if (condition)
statement
[else
statement]
BY : MANISH ROHILA 2015
for
for (init-expr; test-expr; incr-expr)
statement
C-style looping construct. init-expr assigns the initial value of a counter variable. test-
expr is a relational expression that is evaluated each time before executing the statement.
When test-expr is false, the loop is exited. incr-expr increments the counter variable after
each pass. All the expressions are optional. A missing test-expr is considered to be true.
A series of statements must be put within braces.
do
do
statement
while (expr)
Looping statement. Execute statement, then evaluate expr and, if true, execute statement
again. A series of statements must be put within braces. {N}
Perl:
Operators
lists all the Perl operators from highest to lowest precedence and indicates
their associativity.
You can clarify your expressions by using parentheses to group any part of an
expression. Anything in parentheses will be evaluated as a single unit within a
larger expression.
With very few exceptions, Perl operators act upon scalar values only, not upon list
values.
Terms that take highest precedence in Perl include variables, quote and quotelike
operators, any expression in parentheses, and any function with arguments in
parentheses.
A list operator is a function that can take a list of values as its argument. List operators
take highest precedence when considering what’s to the left of them. They
. Perl associativity and operators, listed by precedence
Associativity Operators
Left Terms and list operators (leftward)
Left -> (method call, dereference)
Nonassociative ++ -- (autoincrement, autodecrement)
Right ** (exponentiation)
Right ! ~ \ and unary + and - (logical not, bit-not,
reference, unary plus, unary minus)
Left =~ !~ (matches, doesn’t match)
Left * / % x (multiply, divide, modulus, string
BY : MANISH ROHILA 2015
replicate)