Unix Tutorial

 
 
 

Basic Programming

Addition on two operands dec, bin, oct, hex Display all user name, or user of group 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 Find position of substring in given string Sort numeric file 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 Menu driven calculator using case Ask your name, program name, enrolement number 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 Count length of user input string Find out difference between two files 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 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 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 List hidden files in current directory Separate colon from given item 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 Count char, lines and words in particular file Check every argument is file or dir 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 Subtraction on operands dec, bin, oct, hex Create pyramid of number 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 Check whether string is palindrome or not Check dir if it exists then change the path 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 Find out sum of numbers using command line arg Find sum, avg and product of four integers 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 Concate two string find length of resultent string Change permission of file as 644 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 Display digit are in odd position in 5 digit no Exchange values of two variables Find position of substring in given string 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 Find out common lines between two files Display current working directory 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 Count no of words, char, space, symbols Check whether such files already exist 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 Names of all sub-directory in current directory Hard Link, Soft Link, Counting each of links 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 Convert contents into uppercase in particular file Renaming each files in dir 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
 
 
clear
i=\"y\"
a=0
t=0
while [ $i = \"y\" ]

do
clear
echo \"1.Compare 2 strings :\"
echo \"2.Concatanet string\"
echo \"3.Find length of string\"
echo \"4.Occurance of word\"
echo \"5.Reverse of string\"
echo \"6.Exit\"
echo \"Enter your choice\"
read ch
case $ch in
    1)echo \"Enter first String\"
     read s1
     echo \"Enter second string \"
     read s2
     if [ $s1 = $s2 ]
     then    
        echo \"Two strings are equal \"
     else
        echo \"Two strings are not equal\"
     fi;;
    2)echo \"Enter one string \"
      read s1
     echo \"Enter second string \"
     read s2
     echo $s1 $s2;;
    3)echo \"Enter any String\"
     read s1
     t=\`echo $s1|wc -c\`
     t=\`expr $t - 1\`
     echo \"Length of \"$s1\" is \"$t;;
    4)echo \"Enter any String \"
     read s1
     echo \"Enter word u want to find occurance of:\"
     read c1
     t=\`echo $s1|wc -c\`
     t=\`expr $t - 1\`
     echo \"length \"$t
         while [ $t -ne 0 ]
     do
          temp=\`echo $s1|cut -c $t\`
      temp2=\`echo $temp2 $temp\`
          #echo $temp2
       if [ $temp2 = $c1 ]
       then
        a=\`expr $a + 1\`
        t=\`expr $t - 1\`
       else
        t=\`expr $t - 1\`
       fi
    done
     echo \"Occurance of \"$c1\" is \"$a;;
    5)echo \"Enter any string :\"
      read s1
       t=\`echo $s1|wc -c\`
           t=\`expr $t - 1\`
           echo \"length \"$t
           while [ $t -ne 0 ]
       do
         temp=\`echo $s1|cut -c $t\`
         echo $temp
         temp2=\`echo $temp2 $temp\`
         t=\`expr $t - 1\`
      done
      echo $temp2;;
    6)exit;;
    *)echo \"Invalid choice\";;
esac
echo \"Do u want to continue ?\"
read i
if [ $i != \"y\" ]
then
    exit
fi
done

    Related Post:
  1. Write a script to count and report the number of entries in each subdirectory mentioned in the path, which is supplied as a command-line argument

  2. Shell script which receives two file names as arguments and checks whether the two file contents are same or not. If same then delete second file

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

  4. Unix Commands and description of ls,logout,mkdir,rmdir,rm,cd,man,talk,write,pico,pine,more,sz,rz,telnel,ftp,archie,irc,lynx,gopher,tin,trn,passwd etc

  5. Shell Script to create a pyramid of number

  6. Write a shell script for renaming each files in the directory such that it will have the current shell PID as an extension

  7. Write a shell script to reverse a number supplied by a user

  8. Shell script to perform string replacement in a file and view the content of file

  9. Change a permission of a file

  10. Combine two files to a single file

  11. How would we see content of the file?

  12. Program to perform operations like Count char,words and lines of file, display file in reverse, change case and frequency of a particular word in file

  13. Prepare a menu driven calculator

  14. Suppose four filenames are supplied then the first file should get copied into second file, the third file should get copied into four

  15. Write a shell program to search for a given number from the list of numbers provided using binary search method

  16. Calculate 3+4+5+6

  17. Shell script that prints names of all sub-directories present in the current directory

  18. Shell Script to separate the colon from the given item

  19. Shell Script to check file is ordinary or not

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