Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

Write a script which reads a text file and output the following Count of character, words and lines. File in reverse. Frequency of particular word in the file. Lower case letter in place of upper case letter.


clear
echo "Enter File Name :="
read filename
echo "1. Number Of Character"
echo "2. Number Of Words"
echo "3. Number Of Lines"
echo "4. File In Reverse"
echo "5. Fequency Of Particular Word"
echo "6. Convert Upper Case to Lower Case"
echo "Enter Your Choice :="
read ch
case $ch in
 1)
  echo "Total Number Of Characters are : " `cat $filename |wc -c` 
  ;;
 2)
  echo "Total Number Of Words are : " `cat $filename |wc -w` 
  ;;
 3)
  echo "Total Number Of Lines are : " `cat $filename |wc -l` 
  ;;
 4) 
  revstr=""
  while read -n1 ch;
  do
   revstr="$ch$revstr"
  done<$filename
  echo "File In Reverse Order : "
  echo $revstr
  ;;
 5)
  clear
  echo "Enter Word To Search : "
  read search
  filename="veer.txt"
  str=`grep -i "$search" $filename`
  `echo $str | tr '[A-Z]' '[a-z]'>file.txt`
  i=1
  count=0
  len=`echo $str | wc -c`
  echo "length is $len"
  search=`echo $search|tr '[A-Z]' '[a-z]'`
  echo "SEARCH WORD:$search"
  i=1
  while read -n1 ch;
  do
   if [ "$ch" == " " ] || [ $i -eq $len ];then
    if [ "$word" == "$search" ];then
     count=`expr $count + 1`
    fi
    word=""
   else
    word="$word$ch"
   fi
   i=`expr $i + 1`
  donefile.txt`
  `cat file.txt > $filename`
  echo "ALL CHARACTER CONVERTED TO LOWER CASE"
  ;;
 *)
  echo "Enter poper Values "
esac

Output: 

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes