Sqllab
Sqllab
hour=$(date +%H)
if (( hour >= 5 && hour < 12 )); then
echo "Good morning"
elif (( hour >= 12 && hour < 18 )); then
echo "Good afternoon"
else
echo "Good evening"
fi
simple calculator
# !/bin/bash
Write a program to find out biggest number from given three nos.
#!/bin/bash
avg=$((sum / ${#nums[@]}))
echo "The average is: $avg"
Write script to print given number in reverse order, for eg. If no is 123 it must print as 321. (use
while loop).
if [ $# -ne 1 ]
then
echo "Usage: $0 number"
echo " I will find reverse of given number" echo " For eg. $0 123, I will print 321" exit 1
fi
n=$1
rev=0
sd=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
rev=`expr $rev \* 10 + $sd`
n=`expr $n / 10`
done
echo "Reverse number is $rev"
write a shell script to print contains of file from given line num to next given line num
for($i=1;$i<10 ;$i++ )
{
printf $i^2 . "\n";
}
Creating variable
#!/usr/bin/perl
@ages = (25, 30, 40);
@names = ("John Paul", "Lisa", "Kumar");
print "\$ages[0] = $ages[0]\n";
print "\$ages[1] = $ages[1]\n";
print "\$ages[2] = $ages[2]\n";
print "\$names[0] = $names[0]\n";
print "\$names[1] = $names[1]\n";
print "\$names[2] = $names[2]\n";
$age = 25; # An integer assignment
$name = "John Paul"; # A string
$salary = 1445.50; # A floating point
print "Age = $age\n";
print "Name = $name\n";
print "Salary = $salary\n";
write an awk script to find the no of characters, words and lines in a file .(online compiler)
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
}
write an awk script to count number of lines in a file that does not contain vowels
decimal to hex