Sunday, 3 March 2019

UNIX CODES

UNIX - FindDepartmentEmployeeCount

#!/bin/bash
#write your code here
if [ $# -ne 2 ]
then
echo "Pass appropriate number of command line arguments"
elif [ -d $1 ]
then
echo "Input file is not an ordinary file"

elif [ ! -f $1 ]
then
echo "Input file does not exists"
elif [ ! -r $1 ]
then
echo "Input file does not have read permission"
else
grep -i $2 $1 | wc -l
fi

UNIX - CountWords

#!/bin/bash
#write your code here
if [ $# -ne 2 ]
then
echo "Pass appropriate number of command line arguments"
elif [ -d $1 ]
then
echo "Input file is not an ordinary file"
elif [ ! -f $1 ]
then
echo "Input file does not exists"
elif [ ! -r $1 ]
then
echo "Input file does not have read permission"
else
grep -i $2 $1 | wc -l
fi

UNIX - COUNT EMPTY FILES

j=0
k=0
count=0
total=0
for i in $@
do
if [ -s $i ]
then
count=`wc -w $i|cut -d ' ' -f 1`
let total=$count+$total
let k=$k+1
else
let j=$j+1
fi
done
echo $

UNIX - STUDENTS RECORDS


UN IX-AVREAGE SALARY
sum=0
count=0
firstLine=0
found=0

if [ $# -ne 2 ] ; then
echo "Pass appropriate number of command line arguments"
elif [ -d $1 ]; then
echo "Input file is not an ordinary file"
elif [ ! -f $1 ] ; then
echo "Input file does not exist"
elif [ ! -r $1 ]; then
echo "Input file does not have read permission"
else
while read -r line; do
if [ $firstLine -eq 0 ] ; then
firstLine=1
else
while IFS=',' read -r a b c; do
if [ $b = $2 ] ; then
found=1
sum="$(($sum + $c))"
count="$(($count + 1))"
fi
done <<< "$line"
fi
done < "$1"
avg="$(($sum / $count))"
if [ $found -eq 0] ; then
echo "Given designation not found"
else
echo $avg
fi
fi


13 comments:

  1. thakx mate fiannly unix code

    ReplyDelete
  2. have a question for you ?
    how on earth you were able to solve this unix questions.
    Please let me know as well so i can do them by myself as well

    ReplyDelete
  3. 2nd and 3rd codes are same .

    ReplyDelete
  4. Count empty files is not passing all test cases... Its just passing 1 test case

    ReplyDelete
  5. Count Empty files

    j=0
    k=0
    count=0
    total=0
    for i in $@
    do
    if [ -s $i ]
    then
    count=`wc -w $i|cut -d ' ' -f 1`
    let total=$count+$total
    let k=$k+1
    else
    let j=$j+1
    fi
    done
    echo $j

    ReplyDelete
  6. 1 ,2 ND last code of Unix is same ...

    ReplyDelete
  7. please provide the student marks unix program

    ReplyDelete
  8. Yeah please provide Student_Marks Unix code.

    ReplyDelete
  9. sir can you please post the answer for skill upgrade unix hands on answer please

    ReplyDelete
  10. First one is not running properly....not a single case passed

    ReplyDelete
  11. Showing syntax error with unexpected token 'else

    ReplyDelete

ASP.NET Core: How to implement Azure Active Directory (AAD) Authentication in ASP.NET Core

  In this tutorial, we will implement security for ASP.NET Core Application using Azure Active Directory (AAD).  In this tutorial, I will co...