NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

This is for the 1st:
#!/bin/bash
echo "Do you want to continue (y/n)"
read go
while [[ "$go" != "n" ]] #function where user may use yes or no
do

tatts_function-len() #function of length
{

echo -n "Enter the lenght of the rectangle in cm: "

read -n10 leng #taking the input of length which was insert by user

if [[ $leng =~ ^[0-9]+.?[0-9]*$ ]]; then #taking only number from user not any alphabetical letter

echo "width of a rectangle is $leng cm"

else


echo -n "(Enter number)"
tatts_function-len #end function length
#read leng
fi

}

tatts_function-len

tatts_function-bre() #function of breadth
{
echo -n "Enter the breadth of the rectangle in cm: "

read -n10 bra #taking the input of breadth which was insert by user

if [[ $bra =~ ^[0-9]+.?[0-9]*$ ]]; then #taking only number from user not any alphabetical letter

echo "height of rectangle is $bra cm"

else


echo -n "(Enter number)" #if user put alphabetical word then input may ask enter number to execute the program
funcbredth
#read b
fi
}
tatts_function-bre


echo " Area of the rectangle is : $leng * $bra " #print the value of length and breadth of rectangle



Arr=`echo $leng * $bra |bc` #calculate the rectangle in cm

echo "Area of the rectangle in cm = $Arr cm" #show the final output of area of rectangle

In=`echo $Arr / 2.54 |bc` #calculate the area of rectangle in inch

echo "Area of rectangle in inch = $In inch " #show the input in inch form
echo "Do you want to continue? (y/n)" #user can be continue or end the function
read go
done


This is for the another:
#!/bin/bash
#bonus.sh

bastola_sales()
{
echo "Enter the number of salesperson:" #display message to put number salesperson
read put #taking the value of number
if [[ $put =~ ^[0-9]*$ ]] #check the value in number form
then
bastola_read
else
bastola_sales #read the salesperson
fi # close for loop
}
bastola_read()
{
for (( a = 0; a < $put; a++ )) #satrting for loop for put function
do
echo "Enter the name of sales person $a: " #display the name of sales
read bastola_name #read bastola_name
if [[ $bastola_name =~ ^[A-Z|a-z]+$ ]] #pressing the s key from keyboard to sort in alphabetical
then
name1[$a]="$bastola_name" #read the value of $a

echo "Enter quarterlysales of a person $a: " #enter the value of quartarley
read bastola_quarter
if [[ $bastola_quarter =~ ^[0-9]*$ ]] #check the number only while put
then
quarterly1[$a]="$bastola_quarter" #check the value of quarterly
fi


else
bastola_read
fi

if [[ $bastola_quarter -gt 1000000 ]] #display the bonus
then
bonus[$a]="1,500"
elif [[ $bastola_quarter -le 999999 && $bastola_quarter -ge 1000000 ]]
then
bonus[$a]="750"
elif [[ $bastola_quarter -le 99999 ]]
then
bonus[$a]="0"
fi
done
bastola_display #save all file in savedarjun.txt
bastola_display >> savedarjun.txt
}

bastola_display()
{
for (( a = 0; a < $put; a++ )) #listing all bastola_name and sales quarterly
do
echo "Names:" ${name1[@]} #display name of sales
echo "Quarterlysales:" ${quarterly1[@]} #displat quarterly sales
echo "Bonus:" ${bonus[@]} #display bonus
bastola_option
done

}
bastola_option(){
echo "Press S for sorting sales and A for alphabetic" #user need tp press s key for sorting sales and pressing a key from keybroad for sorting alphabetical order
read put
if [[ $put =~ ^[A]$ ]] || [[ $put =~ ^[a]$ ]] #check put is equal to output for alphabetical
then
bastola_bubble_sort1
elif [[ $put =~ ^[S]$ ]] || [[ $put =~ ^[s]$ ]] #using bubble sort for sorting sales
then
bastola_bubble_sort
else
exit
fi
}
bastola_bubble_sort() #using bubble sort for display the sorting sales and alphabetical order
{
n=${#quarterly1[@]} #this line of code show sorting the salesperson and quarterly in sales
for ((k=0;k<$n;k++))
do
for ((l=0;l<$n;l++))
do
if [[ ${quarterly1[l]} -lt ${quarterly1[$((l+1))]} ]]
then
t=${quarterly1[$j]}
quarterly[$l]=${quarterly1[$((l+1))]}
quarterly[$((l+1))]=$t

t1=${name1[$l]}
name[$l]=${name1[$((l+1))]}
name[$((l+1))]=$t1
fi
done
done
echo ${name1[*]}
echo ${quarterly1[*]}
}

bastola_bubble_sort1()
{
n=${#name1[@]} #this line of code show sorting the salesperson and quarterly in alphabetical order
for ((k=0;k<$n;k++))
do
for ((l=0;l<$n;l++))
do
if [[ ${name1[l]} > ${name1[$((l+1))]} ]]
then
t=${name1[$l]}
name[$l]=${name1[$((l+1))]}
name[$((l+1))]=$t

t1=${quarterly1[$j]}
quarterly[$j]=${quarterly1[$((l+1))]}
quarterly[$((l+1))]=$t1
fi
done
done
echo ${name1[*]} #display bastola_name and quarterly in decending sales form
echo ${quarterly1[*]} #display bastola_name and quarterly in aplphabetical order
}


continue()
{
echo "Do you want to continue?Press[Yy]" #display the message user can be continue or not
read continue
if [[ $continue =~ ^[Y]$ ]] || [[ $continue =~ ^[y]$ ]]
then
clear
Salesperson
else
exit
fi
}
bastola_sales

#!/bin/bash

echo "1: Backup" #display the backup input
echo "2: bastola_user Management" #display the bastola_usermanagement input

while [ 1 ] #bastola_user need to press 1 key for backup programming code or execute the backup code
do

read bastola_menu #create a bastola_menubar for backup
case $bastola_menu in
1)
echo "Backup for Zip" #dispaly the zip format how to create zip file
echo "a: backup now" #bastola_user can be archieve in manal form using tar command
echo "b: set backup timer " # or bastola_user can be archieve in form of automatic backup using corntab

while [ 1 ] #using while loop
do
read backup #read backup
case $backup in #using case
a) #pressing a key for backup now
sudo tar -cvpzf backup.tar.gz /root #using tar command for manual backup
;;
b) #pressing b key for automatic backup
echo "This is for scheduled backup"
echo -n "Enter the minute Example:Enter */1 for every minute:" #time set in minute
read a
echo -n "Enter hour (*") from 0-23:" #time set in hour
read b
echo -n "Enter day of month (*) from 0-30:" #time set in hour
read c
echo -n "Enter month (*) from 1-12:" #time set in month
read d
echo -n "Enter day of week (*) from 0-7 as 0 being monday:" #time set in ween as being monday
read e
echo -n "Name of the backup file:" #create folder name
read f
echo -n "path of backup file (example:new/newfolder):" #create path for save thr backup file
read g
echo -n "Name of bastola_source:" #name of bastola_source of backup file
read bastola_source

echo "$a $b $c $d $e tar -cpzf ~/$g/$f /root/$bastola_source " >> crontab.txt
crontab crontab.txt #save in zip file
;;
End)
break
;;
*)
echo "Choose option a-b or "End" to exit"
;;
esac
done
;;
2)
echo "bastola_user Mangement" #display the bastola_usermanagement
echo "a: Add new group" #print add new group
echo "b: Add new bastola_users" #print add new bastola_users
echo "c: Delete bastola_users" #print delete bastola_users
echo "d: Delete group" #print delete group
echo "e: Edit bastola_users" #print edit bastola_users
echo "f: Edit groups" #print edit group
echo "End: To exit" #end to exit the progarm
while [ 1 ]
do
read bastola_user #read bastola_user
case $bastola_user in #using case
a)
echo "Add a new Group"
echo -n "Enter group name:"
read NG #read group name
sudo addgroup $NG
;;
b)
echo "Add a New bastola_user"
echo -n "Enter bastola_user name:"
read bastola_userADD #create bastola_useradd
#echo -n "Enter password:"
#read P
sudo bastola_useradd -m $bastola_userADD #create bastola_useradd
sudo passwd $bastola_userADD #password for bastola_useradd
;;
c)
echo "Delete a bastola_user"
echo -n "Enter bastola_username to be deleated:"
read DELETE #read delete
sudo bastola_userdel $DELETE #bastola_user can be delete
;;
d)
echo "Delete a Group"
groups
echo -n "Name of the group to be delete:"
read delete
sudo groupdel $delete #group can be deleted
;;
e)
echo "choose to edit bastola_users"
echo -n "Enter name of group to view it:"
read editbastola_user
sudo passwd $editbastola_user #bastola_user can be edit of password
;;
f)
echo "choose to edit groups"
echo -n "Enter groupname to add bastola_user:"
read editgroup
echo -n "Enter bastola_username to add bastola_user in group:"
read addbastola_useringroup #read add bastola_user in group
sudo bastola_usermod -a -G $editgroup $addbastola_useringroup #create bastola_user in group
;;
End)
break
;;
*)
echo "choose option from a to f(a-f) or "Exit" to exit" #end the program
esac
done
;;
End)
break
;;
*)
echo "Choose options 1-2 or "End" to quit" #end the program
;;
esac
done



     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.