Headlines
Loading...
Program in UNIX - Filename displayed

Program in UNIX - Filename displayed

The word unix is present in only some of the files supplied as arguments to the shell script. Your shell script should search each of these files in turn and stop at the first file that it encounters containing the word unix. This filename should be displayed on the screen.
while [ $# -gt 0 ]
do
        a=`grep -i "unix" $1 | wc -l`

        if [ $a -gt 0 ]
        then
                echo "file name is $1"
                exit 0
        fi

        shift
done
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***