Unix Tutorial


Basic Programming

Identify directory and executable file Calculate the gross salary Cconcatenate contents of 2 files

General Programs

Combine two files to single file Find gcd for 2 given numbers Command work as spelling checker Check whether string is palindrome or not Check dir if it exists then change the path Compare string, concat, length, occurrence of word Make file,dir display cur dir,list,make,change dir Check two file contents are same or not Prime numbers from 1 to 300 Check file is ordinary or not Display message, user name, terminal name etc Identify directory and executable file Find out sum of numbers using command line arg Find sum, avg and product of four integers Create directory and remove directory Get today\’s date Menu driven script for Copy, Remove, Move file

Directory Programs

Sort file abc.txt and save sorted file in xyz.txt Find largest among 3 given numbers Information about all current program running Concate two string find length of resultent string Change permission of file as 644 Delete file from every dir above present dir Display Current dir, List dir, Make, Change dir Calculate factorial of number Spell cmd on file, Collect list - spelling error Echo suitable message if less then ten char Append abc.txt, xyz .txt Display digit are in odd position in 5 digit no Exchange values of two variables Find position of substring in given string Calendar of December 2006 Reverse the contents of file

Date, time, year Program

Convert first1.txt file to hidden file Find sum, avg and product of four integers Take Logname,UID find terminal this user logged in Machine\’s name in the network Find out common lines between two files Display current working directory Check dir directory if it exists then change path Menu driven calculator Measure size of a file Sort file See content of the file Add, sub and mul 2 no passed as command line arg Reverse number supplied by user Count no of words, char, space, symbols Check whether such files already exist Leap year or not Copy first file to second, third to four

Searching Programs

Count number of words, lines and char of file Find sum of digits of number Find total no. of user and currently loggedin Print message shown in description Count no of character in file Names of all sub-directory in current directory Hard Link, Soft Link, Counting each of links Delete directory with files Convert distance in meters,feet,inches,centimeter Change extension of an existing file Sort Numeric file Create file with 10 lines, display from 5 to 8 Find sum of series sum=1+1/2+...+1/n Functionality of “mv” command with example Convert contents into uppercase in particular file Renaming each files in dir Display time in word Name,size of file in dir exceeding 1000 byte Display ls -l command result for inputted file Calculate 3+4+5+6 Combine file in file horizontally and vertically Show msg “Good Morning/Good afternoon on time Count no.of lines in file abc Addition on two operands dec, bin, oct, hex Display all user name, or user of group Create and remove more than one dir together Enhance calendar to accept any month Find lines containing number in file

File Programs

Split large file into small files Display alternate digit in 7 digit number Users currently working Find position of substring in given string Sort numeric file Perform string replacement in file Delete zero sized files from dir, sub-dir Check inputted dir is in current directory or not Find value of number raised to power of another Display name of files having multiple links Display message, user name, terminal name etc Display file in column format Menu driven calculator using case Ask your name, program name, enrolement number Remove entire directory structure Calendar of 2007 Convert file to lower case or upper case

Mathematical Program

List all hidden files in current directory Display digit which are odd position in 5 digit no Display login name,terminal name,date,time Count length of user input string Find out difference between two files Count and report no of entries in subdirectory Calculate sum of its digits Copy, rename, delete, edit file Binary search method Copy abc.txt into xyz Find avg of no entered in command line Broadcast msg to specified user when loged on Find lines in file with words longer than 4 char Search files and rename Morning, afternoon, Evening wish based on time List of file have read, write, execute permission

String Programs

Rename file from first1.txt to first2.txt Print first 5 odd numbers Prepare marksheet of the student Name of users who are login Compare two files List hidden files in current directory Separate colon from given item Print name of sub-dir present in current dir Calculate area & perimeter of rectangle DB operation like view, add, delete records Bubble sort Change permission of file Find smallest of three numbers Change term, prompt and user list of unix sys Count char, lines and words in particular file Check every argument is file or dir Display exit status search string from string Receive list of file name which are wordfile

Sorting Programs

List all files start with a or A Calculate 9/5 Receive log name, obtain info from /etc/passswd Count number of words, lines and char of file Count no.of words in file abc Subtraction on operands dec, bin, oct, hex Create pyramid of number
if [ $# -eq 1 ]
        if [ -f $1 ]
            a=\`rev $1\`
            echo \"Reverse of $1\"
                cat $1
            echo \" is-> $a\"
            echo \"File does not exist \'

        echo \"Please enter file name or path\"



    $ sh35  wordfile1
    Reverse of
    is-> elppa
$ sh10 sh9
-rwxrwxrwx  1 root     Everyone     262 Dec  7 18:48 sh9
$ sh10 /etc
total 813
-rwxrwxrwx  1 root     Everyone      46 Feb 15  1999 crontab
-rwxrwxrwx  1 root     Everyone     559 Dec  7 17:19 group
-rwxrwxrwx  1 root     Everyone   62464 Feb 15  1999 in.ftpd
-rwxrwxrwx  1 root     Everyone   35328 Feb  1  2000 in.rlogind
-rwxrwxrwx  1 root     Everyone   35328 Feb  3  2000 in.rshd
-rwxrwxrwx  1 root     Everyone   45056 Feb  1  2000 in.telnetd
-rwxrwxrwx  1 root     Everyone    4386 Jun  3  1999 inetd.conf
-rwxrwxrwx  1 root     Everyone   43520 Aug 25  2000 inetd.exe
-rwxrwxrwx  1 root     Everyone    1918 Jul  2  1999 inetdconfig.sh
-rwxrwxrwx  1 root     Everyone   21504 Feb 17  1999 init.exe
-rwxrwxrwx  1 root     Everyone       2 Jan  5  1999 login.allow
-rwxrwxrwx  1 root     Everyone       0 Dec  5  1998 login.deny
-rwxrwxrwx  1 root     Everyone     149 Mar  2  1999 mailx.rc
-rwxrwxrwx  1 root     Everyone   19968 Feb 17  1999 mkpasswd.exe
-rwxrwxrwx  1 root     Everyone     805 Dec  7 17:19 passwd
-rwxrwxrwx  1 root     Everyone     118 Feb  1  2000 passwd.add
-rwxrwxrwx  1 root     Everyone   25088 Feb 17  1999 priv.exe
-rwxrwxrwx  1 root     Everyone    1021 Jun 13  2000 profile
-rwxrwxrwx  1 root     Everyone     500 May 24  2000 rc
lrwxrwxrwx  1 root     Everyone      25 Dec  5 09:08 services -> /sys/drivers/etc/services
-rwxrwxrwx  1 root     Everyone      88 Feb 16  1999 shells
-rwxrwxrwx  1 root     Everyone     384 Dec  5 09:09 sidtable
-rwxrwxrwx  1 root     Everyone    1637 Jun  3  1999 stop_uwin
-rwxrwxrwx  1 root     Everyone       0 Dec  5 09:09 tryme
-rwxrwxrwx  1 root     Everyone   35840 Jun  7  2000 ucs.exe
-rwxrwxrwx  1 root     Everyone   76288 Jun 16  2000 ums.exe
$ sh10 /dev/null-rwxrwxrwx  1 root     Everyone       0 Dec  6 00:44 /dev/null  

    Related Post:
  1. Display your login name

  2. Program to convert and print this distance in meters, feet, inches and centimeters

  3. Print message a shown in description

  4. Write a shell program to concatenate the contents of 2 files

  5. Shell script to check dir directory if it exists then change the path, if not then create dir with that name and also check for file name not exists

  6. Write a shells scripts which will receives a list of filenames,the first of whch would be wordfile

  7. Shell Script to find out the sum of the given numbers using command line argument

  8. Remove entire directory structure

  9. Shell script that takes filename or the filename with its full path as an input during execution and display ls -l command result for inputted file

  10. Write a shell script to sort the given numbers in descending order using Bubble sort

  11. Write a shell script that takes a file names as a argument and deletes this file from every directory above the present working directory.

  12. Write a shell script to convert a file to lower case or upper case as specified by user.

  13. Script to count and report the number of entries present in each subdirectory mentioned in the path, which is supplied as a command-line argument

  14. Shell Script to create a pyramid of number

  15. Change a permission of a file

  16. Shell script to perform database operations for student data like view, add and delete records

  17. Write a shell script, which displays a list of all files in the current directory to which you have read, write and execute permissions

  18. Shell script for following conditions. Take two files as input and run spell command on it, Collect a list of potential spelling errors, modify file

  19. Write a shell program to count number of words, characters,white spaces and special symbols in a givin text

  20. Write a shell program to convert all the contents into the uppercase in a particular file

Didn't find what you were looking for? Find more on Write a shell script to reverse the contents of a file