Sqlkab2 1
Sqlkab2 1
Write a shell script to print contains of file from given line number to next given
number of lines
read f
read s
read e
sed -n $s,$e\p $f
a=10
b=20
sum=$(( $a + $b ))
echo $sum
----------------------------------------------------------------------------------------------------------------------
first=5
second=10
temp=$first
first=$second
second=$temp
read y
then
else
fi
-------------------------------------------------------------------------------------------------------------------------
read a
read b
sum=$(( $a + $b ))
read a
read b
sum=$(( $a * $b ))
-------------------------------------------------------------------------------------------------------------
read a
read b
sum=$(( $a + $b ))
Write a program to find out biggest number from given three nos.
#!/bin/bash
read a
read b
read c
if [ $a -gt $b -a $a -gt $c ]
then
then
echo $b is the biggest number
else
fi
----------------------------------------------------------------------------------------------------------------------
5A. create a Linux shell script program to print program name using command-line.
#!/bin/bash
# shell script program to print program name using command line argument.
read a
read b
read c
------------------------------------------------------------------------------------------------------------------
A. create a Linux shell script program to create and print the value of variables.
country="India"
year=2021
echo "Country name: $country"
B. Write script to print given number in reverse order, for eg. If no is 123 it must print
read num
while [ $num != 0 ]
do
d=$(($num % 10 ))
num=$(($num / 10 ))
done
echo $rev
-----------------------------------------------------------------------------------------------------------------
system.
hour=$(date +%H)
greet="Good morning"
greet="Good afternoon"
else
fi
echo “$greet”
------------------------------------------------------------------------------------------------------------------
read n
do
do
done
do
echo -n "*"
done
echo ""
done
do
do
done
do
echo -n "*"
done
echo ""
done
(for diamond)
For inverted pattern
----
-------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
read var
if [ -d $var ]
then
elif [ -f $var ]
then
#if the provided argument is not file and directory then it does not exist on the system.
else
echo "The given argument does not exist on the file system."
fi
read var
ls "$var"|wc -l
--------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
B. write an awk script to find the no of characters, words and lines in a file.
BEGIN{}
{
print len=length($0),"\t",$0
wordcount+=NF
chrcnt+=len
}
END {
print "total characters",chrcnt
print "Number of Lines are",NR
print "No of Words count:",wordcount
}
-------------------------------------------------------------------------------------------------------------------
. B. write an awk script to count number of lines in a file that does not contain vowels.
echo "Enter file name"
read file
awk '$0!~/[aeiou]/{ count++ }
END{print "The number of lines that does not contain vowels are: ",count}' $file
-------------------------------------------------------------------------------------------------
for($i=1;$i<10 ;$i++ )
----------------------------------------------------------------------------------------------------------------