Shell Script To Count Vowels, Blank Spaces, Characters, Number of line and Symbols

in Categories Academic, Decision Making, String Management last updated February 20, 2009


Share this on:

12 comment

  1. #!/bin/bash
    ### Script to count vowels, no.of lines,blank spaces, words in a given file
    echo " Enter the file name "
    read a
    char=
    cat $a | wc -m
    echo "The number of characters in file are:" $char
    line=cat $a | wc -l
    echo "The number of lines are:" $line
    vow=cat $a | grep -o "[aAeEiIoOuU]" |wc -l
    echo "The number of vowels are:" $vow
    space=cat $a | grep -o " "| wc -l
    echo "The number of blank spaces are:" $space

  2. i used grep command but it give wrong output .. count vowel and consonant in file
    i think i search only for one time

  3. no need for the loop in counting vowels…

    grep -o “[AEIOUaeiou]” $file|wc -l

    …will do the trick

  4. I need to count number blank records for particular column.

    total record in a file is 100
    total blank in column1 is 40 or so.

    How to get this?

    Thanks in advance
    Umar

  5. Hello Aswin Triadhi

    you can easily replace the word with sed using the following command

    sed ‘s/stopped/idle/g’
    this will replace the word globally…

  6. Halo viviek

    How to replace a word in file text
    I have printers.conf in /var/cups/printers.conf
    and I want replace the State Stopped to State Idle with shell script
    example

    Info MY_PRINT
    DeviceURI hp:/net/hp_LaserJet_4250?ip=88.8.8.223
    State Stopped
    StateTime 1254732779
    Accepting Yes
    Shared Yes
    JobSheets none none
    QuotaPeriod 0
    PageLimit 0
    KLimit 0
    OpPolicy default
    ErrorPolicy stop-printer

    I want replace the State Stopped with State Idle, how ?
    regards

    Have a question? Post it on our forum!