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
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
#!/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
thakx mate fiannly unix code
ReplyDeletehave a question for you ?
ReplyDeletehow 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
2nd and 3rd codes are same .
ReplyDeleteCount empty files is not passing all test cases... Its just passing 1 test case
ReplyDeleteCount Empty files
ReplyDeletej=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
only 1 test case is passing.
Delete1 ,2 ND last code of Unix is same ...
ReplyDeleteplease provide the student marks unix program
ReplyDeleteYeah please provide Student_Marks Unix code.
ReplyDeletesir can you please post the answer for skill upgrade unix hands on answer please
ReplyDeleteFirst one is not running properly....not a single case passed
ReplyDeleteShowing syntax error with unexpected token 'else
ReplyDeletethanks
ReplyDelete