You are on page 1of 32


Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed, both commercially and non-commercially, by anyone under licenses such as the GNU General Public License. Linux can be installed on a wide variety of computer hardware, ranging from embedded devices such as mobile phones, smartphones and wristwatches to mainframes and supercomputers. Linux is predominantly known for its use in servers; in 2007 Linux's overall share of the server market was estimated at 12.7%, while a 2008 estimate suggested that 60% of all web servers ran Linux. Most desktop computers run either Mac OS X or Microsoft Windows, with Linux having only 1– 2% of the desktop market. However, desktop use of Linux has become increasingly popular in recent years, partly owing to the popular Ubuntu distribution and the emergence of netbooks and smartbooks. Typically Linux is packaged in a format known as a Linux distribution for desktop and server use. Linux distributions include the Linux kernel and all of the supporting software required to run a complete system, such as utilities and libraries, the X Window System, the GNOME and KDE desktop environments, and the Apache HTTP Server. Commonly-used applications with desktop Linux systems include the Mozilla Firefox web-browser and the office application suite. The name "Linux" comes from the Linux kernel, originally written in 1991 by Linus Torvalds. The contribution of a supporting Userland in the form of system tools and libraries from the GNU Project (announced in 1983 by Richard Stallman) is the basis for the Free Software Foundation's preferred name GNU/Linux.

Linux is a monolithic kernel. Device drivers and kernel extensions run in kernel space (ring 0 in many CPU architectures), with full access to the hardware, although some exceptions run in user space. The graphics system most people use with Linux doesn't run in the kernel, in contrast to that found in Microsoft Windows. Kernel mode preemption allows device drivers to be preempted under certain conditions. This feature was added to handle hardware interrupts correctly and improve support for symmetric multiprocessing (SMP). Preemption also improves latency, increasing responsiveness and making Linux more suitable for real-time applications.

Kernel panic
In Linux, a "panic" is an unrecoverable system error detected by the kernel as opposed to similar errors detected by user space code. It is possible for kernel code to indicate such a condition by calling the panic function located in the header file sys/system.h. However, most panics are the result of unhandled processor exceptions in kernel code, such as references to invalid memory addresses. These are typically indicative of a bug somewhere in the call chain leading to the panic. They can also indicate a failure of hardware, such as a failed RAM cell or errors in arithmetic functions in the processor caused by a processor bug, overheating/damaged processor, or a soft error.

Programming languages
Linux is written in the version of the C programming language supported by GCC (which has introduced a number of extensions and changes to standard C), together with a number of short sections of code written in the assembly language (in GCC's "AT&T-style" syntax) of the target architecture. Because of the extensions to C it supports, GCC was for a long time the only compiler capable of correctly building Linux. In 2004, Intel claimed to have modified the kernel so that its C compiler also was capable of compiling it. There was another such reported success in 2009 with a modified 2.6.22. Many other languages are used in some way, primarily in connection with the kernel build process (the methods whereby the bootable image is created from the sources). These include Perl, Python, and various shell scripting languages. Some drivers may also be written in C++, Fortran, or other languages, but this is strongly discouraged. Linux's build system only officially supports GCC as a kernel and driver compiler.

While not originally designed to be portable, Linux is now one of the most widely ported operating system kernels, running on a diverse range of systems from the iPAQ (a handheld computer) to the IBM System z9 (a massive mainframe server that can run hundreds or even thousands of concurrent Linux instances). Linux runs as the main operating system on IBM's Blue Gene supercomputers. As of June 2009, Linux is the OS on more than 88% of systems on the Top 500 supercomputers list. Also, Linux has been ported to various handheld devices such as TuxPhone and Apple's

iPod. The Android operating system, developed for mobile phone devices, uses a modified version of the Linux kernel.

Virtual machine architectures
The Linux kernel has extensive support for and runs on many virtual machine architectures both as the host operating system and as a client operating system. The virtual machines usually emulate Intel x 86 families of processors, though in a few cases PowerPC or AMD processors are also emulated.

Features of linux
• • • • • • • • Multitasking: several programs running at the same time. Multiuser: several users on the same machine at the same time (and no twouser licenses!). Multiplatform: runs on many different CPUs, not just Intel. Multiprocessor, Multithreading: has native kernel support for multiple independent threads of control within a single process memory space. Has memory protection between processes, so that one program can't bring the whole system down. Demand loads executables: Linux only reads from disk those parts of a program that are actually used. Shared copy-on-write pages among executables. This means that multiple process can use the same memory to run in. When one tries to write to that memory, that page (4KB piece of memory) is copied somewhere else. Copyon-write has two benefits: increasing speed and decreasing memory use. Virtual memory using paging (not swapping whole processes) to disk: to a separate partition or a file in the file system, or both, with the possibility of adding more swapping areas during runtime (yes, they're still called swapping areas). A total of 16 of these 128 MB (2GB in recent kernels) swapping areas can be used at the same time, for a theoretical total of 2 GB of useable swap space. It is simple to increase this if necessary, by changing a few lines of source code. A unified memory pool for user programs and disk cache, so that all free memory can be used for caching, and the cache can be reduced when running large programs. Mostly compatible with POSIX, System V, and BSD at the source level. All source code is available, including the whole kernel and all drivers, the development tools and all user programs; also, all of it is freely distributable. Plenty of commercial programs are being provided for Linux without source, but everything that has been free, including the entire base operating system, is still free. Supports several common file systems, including minix, Xenix, and all the common system V file systems, and has an advanced file system of its own, which offers file systems of up to 4 TB, and names up to 255 characters long.

• • •

1. Low cost: You don’t need to spend time and money to obtain licenses since Linux and much of its software come with the GNU General Public License. You can start to work immediately without worrying that your software may stop

You can restrict the use of specific computers by installing for example only selected office applications instead of the whole suite. from online repositories containing thousands of high quality packages. Full use of hard disk: Linux continues work well even when the hard disk is almost full. there are large repositories from which you can freely download high quality software for almost any task you can think of. No purchase transactions requiring credit card numbers or other sensitive personal information are necessary. Performance: Linux provides persistent high performance on workstations and on networks. You can pick the one you like best. “Walls” and flexible file access permission systems prevent access by unwanted visitors or viruses. 7. 3. a large printing job in the background won’t slow down your other work. Multitasking: Linux is designed to do many things at the same time. 2. 10.working anytime because the free trial version expires.. Choice: The large number of Linux distributions gives you a choice. Flexibility: Linux can be used for high performance server applications. It can handle unusually large numbers of users simultaneously. Stability: Linux doesn’t need to be rebooted periodically to maintain performance levels. and embedded systems. client and server systems can be easily set up on any computer running Linux. Network friendliness: Linux was developed by a group of programmers over the Internet and has therefore strong support for network functionality. 9. Popular Linux distributions come with tools that make installation of additional software very user friendly as well. Each distribution is developed and supported by a different organization. Most Linux applications are Open Source as well. free of charge. . 11. desktop applications.g. Additionally. Compatibility: It runs all common Unix software packages and can process all common file formats. Open Source: If you develop software that requires knowledge or modification of the operating system code. You can save disk space by only installing the components needed for a particular use. e. Linux users have to option to select and safely download software. 12. It doesn’t freeze up or slow down over time due to memory leaks and such. It can perform tasks such as network backups faster and more reliably than alternative systems. Linux’s source code is at your fingertips. 6. Security: Linux is one of the most secure operating systems. and can make old computers sufficiently responsive to be useful again. most software runs on most distributions. Continuous up-times of hundreds of days (up to a year or more) are not uncommon. 5. Fast and easy installation: Most Linux distributions come with user-friendly installation and setup programs. 4. the core functionalities are the same. 8.

Disadvantages • • • • • Because you must learn unix commands. Printed instruction manuals and technical support is much harder to find. The linux GUI does not provide as much functionality as the linux CLI (command line interface). wordprocessing software. it takes longer to learn about linux. . internet explorer and games. Linux does not have an abundance of commercial software such as. Configuring devices in linux is generally more difficult.

and Datacenter Server. and Microsoft increased support for different languages and locale information. Windows 2000 can be installed through either a manual or unattended installation. Faster Multitasking: It allows user to run multiple programs and perform different tasks such as browsing. Microsoft sold Windows 2000 Advanced Server Limited Edition and Windows 2000 Datacenter Server Limited Edition. Advanced Server. it continues to receive patches for security vulnerabilities nearly every month and will continue to do so until 13 July 2010. it was the successor to Windows NT 4.0 with a number of new assistive technologies. and servers. Features of Windows 2000 1. and is the final release of Microsoft Windows to display the "Windows NT" designation. Setup Manager: Setup Manager provides a graphic interface to the users to make installation scripts. and can be performed through a bootable CD using Microsoft Systems Management Server. which were released in 2001 and run on 64-bit Intel Itanium microprocessors. Distributed File System (a file system that supports sharing of files) and faultredundant storage volumes.0. by the System Preparation Tool. notebook computers. as well as basic and dynamic disk storage. NTFS 3. Released on 17 February 2000. including many system utilities such as the Microsoft Management Console and standard system administration applications. Unattended installations rely on the use of answer files to fill in installation information. the Encrypting File System.PROGRAM – 2 TO STUDY WINDOWS 2000 OPERATING SYSTEM Windows 2000 is a line of operating systems produced by Microsoft for use on business desktops. including the ability to provide Active Directory services (a hierarchical framework of resources). Microsoft marketed Windows 2000 as the most secure Windows version ever. Four editions of Windows 2000 were released: Professional. but it became the target of a number of high-profile virus attacks such as Code Red and Nimda. While each edition of Windows 2000 was targeted to a different market. . Additionally. 2.0. Support for people with disabilities has been improved over Windows NT 4. Server. Over ten years after its release. The Windows 2000 Server family has additional features. All versions of the operating system support the Windows NT file system. they share a core set of features. It was succeeded by Windows XP for desktop systems in October 2001 and Windows Server 2003 for servers in April 2003. listening music. downloading and working on the files at the same time.

9. Plug and Play: More than 65. Synchronization: Synchronization makes your files and folders updated by comparing the files and folders on the network server. Intellimirror technology is useful for the mobile computer users. 4. application settings and user rights. 6. 14. Hibernation: Hibernation is a very useful utility in Windows 2000 Professional and when you re-activate/turn on your computer hibernation restores your programs without losing your data. errors. . The encryption and decryption features provide a security layer to the files and folders. Troubleshooters: It assists users to troubleshoot. 5. Encrypting File System: With EFS each file can be encrypted with the randomly generated key.000 devices support this functionality and it is used for installing the new hardware without the minimum configurations and work at the user end. Microsoft Management Console: MMC provides centralized environment for the management tools and you can access MMC by typing “MMC” at the run. In Virtual Private Networks. Intellimirror requires Windows 2000 server to run and the offline feature enables users to work on their important files when the network connections are unavailable. desktop settings. 10. Personalized Menu: It adapts the start menu to show the applications that you most work on. Auto Correct: Auto Correct feature automatically corrects the URL conventions such as http. Group Policy: Group policy feature of the Windows 2000 Professional operating system enables the System/Network Administrators to define rules about security. 11. Offline Viewing: Offline Viewing feature in Windows 2000 Professional makes entire web pages including graphics for offline view when internet is not available. IPSEC plays an important role in securely transmitting the data to the remote location through internet. IP Security Support: IPSEC is a security protocol that protects the data over the network. which results in greater performance and greater productivity. and . 13. optimize and configure a lot of functionalities of Windows 2000 Professional. com. You can configure a lot of programs and objects through MMC 8. Intellimirror: Intellimirror provides enhanced access to the information and software.3. 12. Group policy works with the active directory and it requires Windows 2000 Server.

date +"%A %j %n %k %p" Tuesday 248 15 PM The default is %a %b %e %T %Z %Y (e. Net Meeting: With Net Meeting Conferencing software you can have real time online chat. sun).15. Tue Sep 5 14:59:37 EDT 2005). jan). 1. Last two digits of year (00-99).. 16. 01) Time in %H:%M:%S format.g. Cable Net etc. For example: &dollar. 17.g. • +%a Abbreviated weekday name (e. Four-digit year (e. Automated Proxy: Automated proxy feature in Windows 2000 Professional automatically locate the proxy server on the network and connect to the internet through that proxy server. jan). • • • • • • • • +%b +%e +%T +%Y +%Z +%m +%h +%y Abbreviated month name (e. Day of month (e.g. Display current date in a nonstandard format.3 TO STUDY THE GENERAL PURPOSE COMMANDS IN LINUX. Alphabetic time zone abbreviation (e. whose values will appear as described in the following entries. EDT).g..g. teleconferencing with the people throughout the world. Internet Connection Sharing: ICS or Internet Connection Sharing connects your home of office computer to the internet through the Dial-Up or broadband internet connection such as DSL.                    PROGRAM . Abbreviated month name (e. Date Print the current Date and Time. Format can consist of literal text strings (blanks must be quoted) as well as field descriptors. Month of year (01-12).g.. A privileged user can change the system's date and time. . You may specify a display format. 2006).g.

An optional system file (default is /etc/utmp) can be supplied to give additional information. 3. process status) command is used to provide information about the currently running processes. list the names of users currently logged in. text-only user interface in Unix-like operating systems for issuing commands and interacting with the system. With no options. • • • -y -1 -3 Display entire year calendar. and the name of the host from which they have logged in. who who [options] [file] Show who is logged into the system. Seconds (00-59). their terminal. or a one-month calendar of the given month and year. Echo also exists as a command built into bash. Year ranges from 1 to 9999. Month ranges from 1 to 12. and it is . echo echo [options] [string] Send (echo) the input string to standard output. including their process identification numbers (PIDs). the time they have been logged in. This is the /bin/echo command.e. Display previous. it sends to standard output.. Minutes (00-59). 4. The basic syntax of ps is ps [options] When ps is used without any options. which is the display monitor by default. Display current month calendar. cal cal [options] [[month] year] Print a 12-month calendar (beginning with January) for the given year. 2. A shell is a program that provides the traditional. • -m Display Monday as the first day of the week. current and next month calendar. With no arguments print a calendar for the current month. 5.• • • • +%D +%H +%M +%S Date in %m/%d/%y format. four items of information for at least two processes currently on the system: the shell and ps. Hour in 24-hour format (00-23). Ps The ps (i.

Example $tty /dev/pts/10 The terminal file name is 10 (a file named 10) resident in the pts directory. 6. TTY. . TIME is the amount of CPU (central processing unit) time in minutes and seconds that the process has been running. key in the following arithmetic expression and then use [ctrl-d] to quit bc. The four items are labeled PID. pwd (Print working directory) Use the pwd command to print the working directory (the current directory you are in). tty tty [options] Print the filename of the terminal connected to standard input.bash by default on Linux. combination of monitor and keyboard) that the user logged into. bc belongs to a family of commands (called filters) that expect input from the keyboard when used without an argument. When bc invoked without arguments. This information is generally only useful on a multi-user network. 7. This directory in turn is under the /dev directory. which can also be found by using the tty command.. 8. CMD is the name of the command that launched the process. is terminated) as soon as its output is displayed. or 'prints' the output of the pwd command (ie: the directory you are in /home in this case) Line 3 uses the cd command (change directory) to move to the /home/rich/www directory Line 4 enters the pwd command again Line 5 shows we are now in the /home/rich/www directory Line 6 is the prompt again. ps itself is a process and it dies (i. TTY (which now stands for terminal type but originally stood for teletype) is the name of the console or terminal (i. TIME and CMD.. bc Calculator.e. Examples: $ bc 12 + 5 17 . Example >pwd /home >cd/home/rich/www >pwd /home/rich/www > Line 1 of this example shows the command pwd has been entered Line 2 displays.e. the cursor keeps on blinking and nothing seems to happen.

and so forth. 2^32 ^ indicate “to the power of” 144 4294967296 Maximum memory possible on a 32-bit machine. where section 1 consists of user commands. using the .42 Not rounded off. Traditionally. ibase=2 11001010 202 Outout in decimal – base 10 The reverse is also possible with obase: obase=2 14 1110 Binary in 14 9. We can make multiple calculations in the same line.g. however. . To convert binary numbers to decimal set ibase (input base) to 2 before you provide the number. as delimeter.42857…… bc is quite useful in converting numbers from one base to another (not exceeding 16). By default. section 2 contains system calls. bc performs only integer computation and truncates the decimal portion it sees. manpages are divided into nine sections. shown in a separate line: 12 * 12 . man locates and prints the named title from the designated reference section. The output of each computation is. 9/5 1 To enable floating-point computation. man man [options] [section] [title] Display information from the online reference manuals.. set scale to the number of digits of precision before you key in the expression: scale=2 17 / 7 2. result is actually 2. man 2 nice). so the section option serves to bypass the most common entry and find an entry of the same name in a different section (e.bc shows the output of the computation in the next line. all sections are consulted.

contains only printable characters.Contains both printable and unprintable characters.PROGRAM 4 TO STUDY THE FILE MANIPULATION COMMANDS IN LINUX. CATEGORIES:• • • Ordinary file Directory file Device file ORDINARY FILE:-Also known as regular file. o Binary file:. DIRECTORY FILE:- . The file is a container for storing information. o Text file:.

txt and combines those files to make file3. rm:. you have to perform these operations on its associated file. cp cp command copies a file. If I want to copy a file named oldfile in a current directory to a file named newfile in a current directory. duplicating the tree structure.txt :.txt are appended at the end of file2. COMMANDS 1. 3. -r recursively copy a directory and its files.txt . cat file1.Display the content of file1. DEVICE FILE:All devices and peripherals are represented by files.txt file2. . cat file1.txt and display the contents of file3.Reads file1.Contents of file1. or >> to append files to an existing file. CAT:displaying and reating files. to end the session.$cat>vidushi Hello Welcome to NGFCET [ctrl-z] $_ 2. To read or write a device. cp oldfile newfile If I want to copy oldfile to other directory for example /tmp then cp oldfile /tmp/newfile. rm filename To delete all files: rm* Options:-i:. use Ctrl-D.txt and file2.txt :.txt.txt>>file2.txt e.g:. Examples cat file1.For making commands more interactive.Deleting files. -p options preserves the modification time and permissions. You can use the > operator to combine several files into a new file. the end-of-file symbol. When appending to an existing file.txt > file3.It contains no data but keeps some details of the file and subdirectories that contains it.txt :. cat [options] [files] Read (concatenate) one or more files and print them on standard output. Useful options available with cp are -p and -r .

Comparing two –l filename ABSOLUTE PERMISSIONS:- .ownership.write x. wc –l filename wc –w filename wc –c filename wc –l-c filename words characters 6. MV:.Renaming files  It renames a file. $ cmp file1 file2 To files are compared byte by byte and the location of first mismatch is echoed to the screen.  It moves a group of files to a different directory. LS:. chmod:. words and characters. size.Counting lines. 7.Changing file permissions Relative permissions:File permissions:r.Listing of all the files in the current directory.execute $ chmod u_x filename $ chmod ugo+r filename Chmod w. CMP:. iii. $ mv <old file name> <New file name> 5.go+r filename.lines OPTIONS:i.4. $ wc filename Output in the format:. ii. 8. OPTIONS:i) $ls-l: listing file attributes like permissions. iv. WC:.

$ls|wc –l/ filename . grep:.By default it displays 10 lines from bottom.$grep –i pattern filename (it ignores uppercase and lower case letters) 14. head -3 filename 11. // It displays 3 lines.output of one becomes input of second command.for numbering $ nl filename Output:1. –l filename 10. WRITABLE AND EXECUTABLE $ chmod 666 filename. // displays 3 lines from bottom $ tail -3 filename 12.Pattern searching $ grep pattern filename Only those lines which have pattern will be displayed. jmdsfk 13.used to display the no of lines of all files. By default it displays 10 lines from starting. hello 2. tail:. pipeline command:. nl:.000 001 010 011 100 101 110 110 OCTAL 0 1 2 3 4 5 6 7 PERMISSIONS ----X -W-WX R-R-X RWRWX SIGNIFICANCE NO PERMISSION EXECUTABLE ONLY WRITEABLE WRITABLE AND EXECUTABLE READABLE READABLE AND EXECUTABLE READABLE AND WRITEABLE READABLE. gud afternoon 3. head:.

Option:. You simply have to do this to remove the directory pis rmdir pis directory must be removed 3.uncompressing a gzipped file-(-d) To restore the original file. Gunzip filename. gzip –d gunzip eg. $wc –l filename 3875302 filename $gzip filename $ wc –c filename 788096 filename. passwd passwd: Change password. . iii. i.gz PROGRAM 5 TO STUDY THE DIRECTORY COMMANDS IN LINUX.To compress the file. 1.15.$gzip filename e. It brings up dialogue that allows you to change your password. we have two options. 2. gzip:.g. Syntax:. ii.gz. mkdir mkdir command is used to create directories.rmdir The rmdir(remove directory ) command removes directories.

By should invoke this command immediately after you log in: $ script script started. Display host name and info of current system options: -r print OS release level -a prints basic info | -s prints the name of the OS (default)                                                                                 PROGRAM­6   WRITE A SCRIPT TO SEE CURRENT DATE. Script:­ printf "current date and time is" date echo "  " printf "the user logged in is" logname . file is typescript $- 5. USERNAME  AND CURRENT DIRECTORY. uname The uname command displays certain features of the operating system running on your machine.4. script(recording your session) If you are doing some important work and wish to keep a log of all your activities. TIME. it simply displays the name of the operating system.

echo "  " printf "and current directory is" pwd   Output:$ sh prog7 current date and time isThu Apr  1 09:23:12 EDT 2010   the user logged in isdeepika   and current directory is/home/deepika                                                PROGRAM­7 WRITE A SCRIPT TO FIND A GIVEN PATTERN IN GIVEN FILE  WHERE PATTERN AND FILENAME ARE GIVEN AS COMMAND    LINE ARGUMENT.     Script:pattern=$1 filename=$2 echo "pattern=" $pattern .

  Script:echo "enter the pattern to be searched" read pname echo "enter the file to be used" .echo "filename=" $filename grep "$pattern" $filename     Output:$ sh prog8 current prog7 pattern= current filename= prog7 printf "current date and time is" printf "and current directory is"                                                   PROGRAM­8 WRITE A SCRIPT TO SEARCH STRING AND FILE LINK FROM  TERMINAL.

       Script:­ echo "the number of arguments given is $#" .read fname echo "searching for $pname from file $fname" grep "$pname" $fname       Output:$ sh prog9 enter the pattern to be searched directory enter the file to be used prog7 searching for directory from file prog7 printf "and current directory is"                                       PROGRAM­9 WRITE A SCRIPT TO ACCEPT TWO FILENAMES AND CHECK IF    BOTH EXISTS AND THEN APPEND ONE FILE TO ANOTHER.

     Script:- .if test ­f $1 then if test ­f $2 then cat $1>>$2 echo "file $1 append to file $2" else echo "file with name $2 does not exist" fi else echo "file with name $1 does not exist" fi     Output:­ $ sh prog10 prog7 abc the number of arguments given is 2 file with name abc does not exist   PROGRAM-10 WRITE A SCRIPT TO FIND THE LARGEST NUMBER FROM    GIVEN THREE NUMBERS.

Script:- .if test $1 ­ge $2 ­a $1 ­ge $3 then echo "the greatest number is $1" elif test $2 ­ge $1 ­a $2 ­ge $3 then echo "the greatest number is $2" else echo "the greatest number is $3" fi   Output:$ sh prog11 56 34 74 the greatest number is 74 PROGRAM .11 WRITE A SCRIPT TO PRINT PYRAMID OF NUMBERS.

i++)) do for(( j=1 . i<=5 . j<=i.for(( i=1 . Script:- . j++)) do printf $i done echo “ ” done Output:1 22 333 4444 55555          PROGRAM-12 WRITE A SCRIPT TO FIND OUT THE LENGTH OF A STRING AND  EXTRACTING A SUBSTRING FROM IT.

*'` echo `expr "$str" : '.\(..\)'` echo `expr "$str1" : '[^d]*d'`     Output:  $ sh prog13 enter your name deepika 7 03 4                                                                     PROGRAM­13 WRITE A SCRIPT USING CASE STATEMENT TO PERFORM  BASIC ARITHMATIC OPERATIONS.str=2003 str1=abcdef echo "enter your name" read name echo `expr "$name" : '.. .

.. /) echo `expr $1 / $3`.Script:case $2 in +) echo `expr $1 + $3`... \*) echo `expr $1 \* $3`. esac    Output:$ sh prog15 12 / 4 3                               PROGRAM­14 WRITE A SCRIPT TO PRINT REVERSE OF A NUMBER. . ­) echo `expr $1 ­ $3`.

Script:  s=0 n=$1 while test $n ­ge 1 do x=`expr $n % 10` n=`expr $n / 10` s=`expr $s \* 10 + $x` done echo "the reverse of digits is " $s   Output:­ sh prog16 34578 the reverse of digits is  87543         PROGRAM-15 .

WRITE A SCRIPT TO PRINT SUM OF DIGITS.  Script:s=0 n=$1 while test $n ­ge 1 do  x=`expr $n % 10` n=`expr $n / 10` s=`expr $s + $x` done echo "the sum of digits is" $s     Output:$ sh prog17 5777 the sum of digits is 26     .

 is armstrong" else echo "the no. Script:  s=0 n=$1 t=$1 while test $n ­ge 1 do x=`expr $n % 10` n=`expr $n / 10` s=`expr $s + $x \* $x \* $x` done if test $t ­eq $s then echo "the no. is not armstrong" fi     Output:$ sh prog18 153 the no. is armstrong   .                                        PROGRAM­16 WRITE A SCRIPT TO FIND IF A GIVEN NUMBER IS ARMSTRONG  OR NOT.

 is palindrome   .   Script:  s=0 n=$1 t=$1 while test $n ­ge 1 do x=`expr $n % 10` n=`expr $n / 10` s=`expr $s \* 10 + $x` done if test $s ­eq $t then echo "the no.                                     PROGRAM­17 WRITE A SCRIPT TO CHECK WHEATHER A NUMBER IS  PALINDROME OR NOT. is palindrome" else echo "not palindrome" fi   Output:$ sh prog19 12321 the no.

Script:­   a=0 b=1 echo $a echo $b while test $1 ­ge $b do a=`expr $a + $b` b=`expr $a + $b` echo $a echo $b done   Output:$ sh prog20 7 0 1 1 2 3 .PROGRAM-18  WRITE A SCRIPT TO PRINT FIBONACCI SERIES.

$2. $3. NR==6{print NR.$3.lst Head –n 2 emp.g.5 8 13 AWK – AN ADVANCE FILTER The AWK command made a late entry into the UNIX system 1977 to augment the tool kit with suitable report formattimg capabilities. Named after its authors. $0.$2.and some of them quite well. Aho.lst SPLITTING A LINE INTO FIELDS:Awk uses the special parameter. In fact. it can do several things. $3.$6}’emp.lst Printf: FORMATTING OUTPUT:$ awk –F”|” ‘/[aA]gg?[ar]+wal/{ > Printf “%3d %-20s %-12s %d\n”. awk. until the advent of perl.lst . SIMPLE AWK FILTERING:Awk options ‘selection criteria {action}’ file(s) The selection criteria filter input and selects lines for the action component to act upon.:$ awk ‘/director/{print}’emp.$2. Awk doesn’t belong to the do-one-nothing-well family of unix commands.$3. Weinberger and Kernighan.$6}’emp. $6}’ emp. was the most powerful utility for text manipulation. to indicate the entire line. $4.NR.g:$ awk –F”|” ‘/sales/ {print $2.lst If you want to select lines 3 to 6 $awk –F”|” ‘ NR==3. e. It also identifies fields bi $1. e.

$2.lst VARIABLES:$awk –F”|” ‘$3==”director” && $6>6700{ >kount=kount+1 >printf “%3d %-20s %-12s %d\n”.g 2:x=”sun”.$6}’emp.$6}’emp.$3.”” K++ } Print $0 .VARIABLES AND EXPRESSIONS:X=”5” Print x e.$3.y print x “.” Y THE COMPARISION OPERATOR:$awk –F”|” ‘$3==”director”||$3==”chairman”{ >printf “%-20s % -12s %d\n”.y=”com” print x.lst LOOPING WITH WHILE:K=0 While(k<(65-length($0))/2){ Printf “%s”.$2.kount.