Thursday, August 27, 2020

bash script

 

http://web.theurbanpenguin.com/training/scripting/mastering-bash-shell-scripting/

http://web.theurbanpenguin.com/category/bash-scripting/


http://web.theurbanpenguin.com/category/bash-scripting/


if statements

//////////////////////////////

syntax

if [ expression ];  

then  

statements  

fi  

//////////////////////////////


example 1

read -p "Enter number:" number

if [ $number -gt 123 ];

then

echo "value is greater than 123"

fi

o/p:value is greater than 123

////////////////////////////////////

example 2

if [ "myfile" == "myfile" ];

then

        echo "its true"

fi

o/p:its true

//////////////////////////////////

For using multiple conditions with AND operator:

''''''''''''''''''''''''''''''''''''''''''''''''''''''

if [ expression_1 ] && [ expression_2 ];  

then  

statements  

fi


example 1

if [ 1 -lt 10 ] && [ 100 -gt 10 ];

then

echo "we won"

fi

o/p: we won

////////////////////////////

For using multiple conditions with OR operator:

if [ expression_1 ] || [ expression_2 ];  

then  

statements  

fi  


case statement example

echo "Enter the arithmetic operation you want to perform?"

echo "A for ADD, S for SUBTRACTION, M FOR MULTIPLY, D FOR DIVISION"

echo "Enter the  operands "

read x

read y

read -p "A|S|M|D" val

case $val in

        A|a)

 sum=$((y+x))

echo $sum

;;

  S|s)

          ((sub=$x-$y))

echo " Subtraction of $x - $y =$sub"

;;

      M|m)

              ((mul=$x*$y))

echo " Multiplication of $x * $y =$mul"

;;

      D|d)

        ((div=$x/$y))

echo "Division of $x/$y =$div"

;;

esac

forloop 
**********************************
syntax

for (( expression1; expression2; expression3 ))  
do  
commands  
done
///////////////////////////////////////
example 1
echo "FINDING SUM OF N NUMBERS"
read x
sum=0
for (( i=0; i<=x; i++ ))
do
        ((sum=sum+i))
done
echo "$sum"
o/p x=5
15
//////////////////////////////////////
syntax

for variable in list  
do  
commands  
done  

example
for num in {1..10}
do
echo $num
done
echo"series of numbers from 1 to 10"
o/p:
1
2
3
4
5
6
7
8
9
10
////////////////////////////////////////////////
For Loop to Read Array Variables
syntax
array=(  "element1" "element 2" .  .  "elementN" )  
  
for i in "${arr[@]}"  
do  
echo $i  
done  

example
arr=( "sun" "moon" "earth" "mars" "venus" "mercury" )
for i in "${arr[@]}"
do
echo $i
done

o/p
sun
moon
earth
mars
venus
mercury
/////////////////////////////////////////////////
For Loop with a Continue Statement
use the 'continue' statement inside the 'for' loop to skip any specific statement on a particular condition. It tells Bash to stop executing that particular iteration of the loop and process the next iteration.

example program to print Numbers from 1 to 20, ignoring from 6 to 15 using continue statement"
for ((i=1; i<=20; i++));
do
if [[ $i -gt 5 && $i -lt 16 ]];
then
continue
fi
echo $i
done
///////////////////////////////////////////////////////////////////
For Loop with a Break Statement
A 'break' statement can be used inside 'for' loop to terminate from the loop.

example
#!/bin/bash
#Table of 2

for table in {2..100..2}
do
        echo $table
        if [ $table == 20 ]; then
                break
        fi
done
o/p:
2
4
6
8
10
12
14
16
18
20

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Infinite Bash For Loop

When there is no 'start, condition, and increment' in the bash three expressions for loop, it becomes an infinite loop. To terminate the infinite loop in Bash, we can press Ctrl+C.

example
i=1;
for (( ; ; ))
do
        sleep 1s
        echo "Current Number: $((i++))"
done


Bash While Loop
****************************
while [ condition ];
 do 
 commands; 
 done  
 
 example
 #!/bin/bash
#Script to get specified numbers

read -p "Enter starting number: " snum
read -p "Enter ending number: " enum

while [[ $snum -le $enum ]];
do
        echo $snum
        ((snum++))
done

echo "This is the sequence that you wanted."
o/p
Enter starting number: 2
Enter ending number: 9
2
3
4
5
6
7
8
9
This is the sequence that you wanted.
////////////////////////////////////////////////////////////
Infinite While Loop
An infinite loop is a loop that has no ending or termination. If the condition always evaluates to true, it creates an infinite loop. 

example
#!/bin/bash
#An infinite while loop

while :;
do
        echo "YOU r in a loop.";
done
  

Friday, May 8, 2020

Job Interview Skills Training

1, Udemy’s Job Interview Skills Training

2. Coursera's Advanced Interview Techniques

3. Edu's English@Work: Basic Job Interview Skills

4. How2Become’s Online Interview Training

5. FutureLearn’s How To Succeed At Interviews

HTML/JS: Making webpages interactive

Advanced JS: Natural Simulations

Advanced JS: Games & Visualizations

Intro to SQL: Querying and managing data

Intro to HTML/CSS: Making webpages

Intro to JS: Drawing & Animation

Monday, February 10, 2020

C++

Image result for features of c++
https://leetcode.com/problems/add-two-numbers/

1. C Programming Absolute Beginner's Guide by Greg Perry and Dean Miller

The 3rd edition of this book is a powerful resource to learn C programming. You can become an expert in these languages with the help of this book. C program examples mentioned in these books is a fast way to get into the comfort zone of learning C language. The book has over 32 chapters, each explains the core concepts of C along with clear examples.

2. Learn C the Hard Way by Zed A

This book is an introduction to modern C programming. The book crafts the knowledge of programming language, making it the perfect choice for all programmers that wish to learn C. Apart from programming concepts, it also discusses skills such as defensive coding, automated testing, illegal memory access, and debugging.

3. Accelerated C++: Practical Programming by Example by Andrew Koenig and Barbara E. Moo
This book is for those who are eager to learn the practical aspects of C++. The book is a part of Stroustrup's C++ in-depth series. It bypasses the basic concepts and directly gets you started with the practical approach of C++. Some of the topics covered in the book include basic string handling, loop, flow control statements, overloading, file I/O, inheritance, virtual functions, and polymorphism.

4. C++ Primer (5th Edition) 5th Edition by Stanley B. Lippman, Josée Lajoie, and Barbara E. Moo

The authors of this book focus on the 2011 revised standard. The book focuses rationale behind the rules for programming in C++. The first part of the book covers basics of the C++ language. The next section deals with the concepts like I/O library, sequential and associative containers, generic algorithms, and dynamic memory. It teaches you high-level programming techniques such as specialised library facilities and tools for large programs.

5. Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14 (1st Edition) by Scott Meyers

This book talks about how you can use the latest features of C++ 11 and C++ 14. The author ensures that you will be able to create software that is correct, efficient, portable, and maintainable. Topics covered in this book include perfect forwarding, except specifications, initialisation, auto type declarations etc. You need to have some basic knowledge of C++ to get started with this book.

Vi Editor

VI EDITOR Move move in the editor: h right j up k  down l left move top shift +g gg down the line of the file :8 go to line 8 search /string...