Informatica Reference

Archive for the ‘Unix Interview Questions’ Category

$vi menu_case.sh
clear
tput cut 10 25
echo “main menu”
tput cut 11 25
echo “————”
tput cut 12 25
echo “1.Date ”
tput cut 13 25
echo “2.All files”
tput cut 13 25
echo “3.All Users”
tput cut 14 25
echo “4.No items found”
read choice
case $choice in
1)echo “Today Date ::” `date`
;;
2)ls -f
;;
3)finger
;;
*)exit
;;
esac
:wq

$vi char_type.sh
echo “enter a character”
read char
case $char in
[a-z])echo “lower case”
;;
[A-Z])echo “upper case”
;;
[0-9])echo “Digit”
;;
?)echo “special character”
;;
*)echo “Entered more than one character”
;;
esac
:wq

$vi twofiles_same.sh
echo “enter first file ”
read f1
echo “enter second file”
read f2
x =`cmp $f1 $f2`
if [-z $x]
then
echo “both are same”
else
echo “both are not same”
fi
:wq

$vi open_file.sh
echo “enter file name:”
read fname
if [ -e $fname ]
then
if [ -f $fname ]
then
if [ -r $fname ]
then
cat $fname
else
chmod u+r $fname
cat $fname
else “it is not a regular file”
else
echo “It is not a regualr file”
else
echo “file doesnt exist”
fi
:wq

$vi type_file.sh
echo “enter file name:”
read fname
if [ -e $fname ]
then
if [ -f $fname ]
then
echo “regular file ”
else
echo “directory file ”
elif [ -l $fname ]
then
echo ” link file”
elif [ -b $fname -o -c $fname ]
then
echo “Device file”
fi
:wq

$vi delete.sh
echo “enter login name:”
read lname
if who | grep $lname > /dev/null
then
echo “user is online”
else
echo “user is offline ”
fi
:wq

$vi delete.sh
echo “enter filename:”
read fname
if rm $fname
then
echo “deleted the file”
else
echo “file is not existed ”
fi
:wq