Unix Tutorial

 
 
 

Basic Programming

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 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 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 Name of users who are login Compare two files 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 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 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 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 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 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 Identify directory and executable file Calculate the gross salary Cconcatenate contents of 2 files

General Programs

Combine two files to single file 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 Machine\’s name in the network 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 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 Check dir directory if it exists then change path Menu driven calculator Measure size of a file Sort file See content of the file 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 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 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 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
 
 
clear 
echo -e \"enter file one : \\c\"
read fone

while [ -z \"$fone\" ] ;
do
echo -e \"request :: please enter file name \"
    echo -e \"\\n\\tfile one : \\c\"
    read fone
done

if [ ! -e $fone ] ; then
    echo -e \"error :: file one $fone doesn\'t exist. can\'t proceed.\"
    read empty
    exit 1
fi

echo -e \"enter file two : \\c\"
read ftwo

while [ -z \"$ftwo\" ];
do
echo -e \"request :: please enter file name \"

    echo -e \"\\n\\tfile two : \\c\"
    read ftwo
done

if [ ! -e $ftwo ] ; then
    echo -e \" error :: file one $ftwo doesn\'t exist. can\'t proceed.\"
    read empty
    exit 1
fi

spell $fone $ftwo > spellerror.log
errword=\`cat spellerror.log | wc -l\`
echo -e \"enter for continue\"

echo -e \"wrong spelling in both fiels : \" 
cat spellerror.log
echo -e \"total wrong words = $errword \"
echo -e \"\\n enter for continue\"
read empty

while [ $errword -gt 0 ] ;
do
    word=\`sed -n \"$errword p\" spellerror.log \`
    echo -e \"word -> $word \"

    echo -e \"do u want update? (y/n) : \\c \"
    read choice

    if [ $choice = \"y\" -o $choice = \"y\" ]; then
        echo -e \"new word : \\c\"
        read newword

        findfile=\`grep -e $word -c $fone\`
        if [ $findfile -gt 0 ]; then
        sed \"s/$word/$newword/g\" $fone > fone.tmp
            mv -f fone.tmp $fone
        fi

        findfile=\`grep -e $word -c $ftwo\`
        if [ $findfile -gt 0 ]; then
        sed \"s/$word/$newword/g\" $ftwo > ftwo.tmp
            mv -f ftwo.tmp $ftwo
        fi
    fi

    errword=\`expr $errword - 1\`

done    

OUTPUT
***********
[04mca58@LINTEL 04mca58]$ sh spell1.sh

enter  file one : 
f1

enter  file two : 
f2                           

enter for continue

                 wrong spelling:- 
ths
fle
chk
purps

 enter for continue                                                  

wrong word -> ths
do u want to update? (y/n) : y
new word : this

wrong word -> fle
do u want to update? (y/n) : y
new word : file

wrong word ->chk
do u want to update? (y/n) : y
new word : check

wrong word -> purps
do u want to update? (y/n) : y
new word : purpose

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

  2. Write a shell script to display the digits which are in odd position in a given 5 digit number

  3. Shell script to display time in word

  4. How to create a directory and remove a directory?

  5. Shell script to take LOGNAME or the UID an an input and find how many terminals has this user logged in

  6. Rename a file from first1.txt to first2.txt

  7. Write a shell program to find the sum of the series sum=1+1/2+...+1/n

  8. 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

  9. Write a shell program to display the alternate digits in a given 7 digit number starting from the first digit

  10. Count no.of lines in file abc?

  11. How to find out difference between two files?

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

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

  14. Sort Numeric file

  15. Menu driven program which has the options Contents of etc/passwd, List of the users who have logged in, Present working directory

  16. Write a Script to Broadcast a message to a specified user when the user loged on any terminal

  17. List all hidden files in current directory

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

  19. Program to calculate the sum of its digits

  20. Write a shell scripts that finds total no. of users and finds out how many of them are currently logged in.