Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Input out put name and birth year: Learning outcome - basic input output and variable
- echo "hello world"
- echo "what is your name?"
- read name
- echo "hello, $name"
- echo "enter your birth year: "
- read n
- #Even odd checking: Learning out come: Basic if, else structure
- #Write a shell script to find whether a number is even or odd.
- #Sample input: 4
- #Sample output : even
- if (( $n%2 == 0 ))
- then
- echo "the number is even"
- else
- echo "the number is odd"
- fi
- #Take an integer input. Show the pyramid with stars(*) in output
- #printing the name 10 times using loop: Learning outcome - Basic loop syntax
- for (( i=0; i<=10; i++))
- do
- echo "my name is $name"
- done
- #printing pyramid: Learning outcome - Loops and nested loops
- echo -n "enter pyramid size: "
- read p
- echo -n "enter pyramid character: "
- read ch
- for(( i=0; i<p; i++))
- do
- for(( j=i; j<p; j++))
- do
- echo -n " "
- done
- for(( k=0; k<=i; k++))
- do
- echo -n "$ch"
- done
- for(( l=0; l<i; l++))
- do
- echo -n "$ch"
- done
- echo ""
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement